這個錯誤也搞了我好久,換了很多版本,后面在網上查到用xlWorkbookNormal來替代 xlExcel?,立馬就可以了。
xlBook.SaveAs(FilePath,Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
發現Office.Interop.Excel.XlFileFormat.xlExcel8格式與本機安裝的office對不上,並且自己也不確定是當前office 版本,最好用Office.Interop.Excel.XlFileFormat.xlWorkbookNormal來替代,讓程序自己去識別。
xlBook.SaveAs(FilePath, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);