作者:乔山办公网日期:
返回目录:excel表格制作
导致这种错误的原因有很多种。可能是因为你的数据太多,或者使用了剪贴板操作。
可以做一下延时处理,最终再生成Excel
我遇到了遇到与你相同的问题,后来发现是要打开的excel模板无法打开错误,模板文件错误。
你这个程序是读取一个本地的XLS内容?我记得好像运行期的时候,读取XLS之前要先关闭EXCEL
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格式636f7079e799bee5baa6364与本机安装的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);