这是代码:
try
{
if (File.Exists("c:\\Reports\\" + fileName))
{
File.Delete("c:\\Reports\\" + fileName);
}
_book.SaveAs("c:\\Reports\\" + fileName, Excel.XlFileFormat.xlWorkbookNormal,
null, null, false, false, Excel.XlSaveAsAccessMode.xlShared,
false, false, null, null, null);
}
catch (Exception ee)
{
throw ee;
}
关于保存为 Excel 格式。我收到以下错误如下..
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
我使用的是 MS Office 2000 版。
使用的Dll是Interop.excel 1.4.0.0
使用 Visual studio 2008 + C# 控制台应用程序
最佳答案
使用 _book.SaveCopyAs("c:\Reports\"+ fileName)
关于c# - 保存到 Excel 文件会导致 C# Windows 中出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10090030/