public static void ConvertExcel(string savePath)
{
//將xml文件轉換為標准的Excel格式
Object Nothing = Missing.Value;//由於yongCOM組件很多值需要用Missing.Value代替
Excel.Application ExclApp = new Excel.ApplicationClass();// 初始化
Excel.Workbook ExclDoc = ExclApp.Workbooks.Open(savePath, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing);//打開Excl工作薄
try
{
Object format = Excel.XlFileFormat.xlWorkbookNormal;//獲取Excl 2007文件格式
ExclApp.DisplayAlerts = false;
ExclDoc.SaveAs(savePath, format, Nothing, Nothing, Nothing, Nothing, Excel.XlSaveAsAccessMode.xlExclusive, Nothing, Nothing, Nothing, Nothing, Nothing);//保存為Excl 2007格式
}
catch (Exception ex) { }
ExclDoc.Close(Nothing, Nothing, Nothing);
ExclApp.Quit();