c# - 保存到 Excel 文件会导致 C# Windows 中出现错误

标签 c# .net windows excel console

这是代码:

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/

相关文章:

执行 WinSCP 脚本时,subprocess.Popen 中的 Python 双引号不起作用

windows - 我应该在 Windows 上使用哪个版本的 Perl?

c# - 无需安装的 C++ 数据库访问

c# - 调用 API 20 次来生成列表,最佳实践?

c# - 移出表单时更改 DragEffect

c# - 未显示子类 UIAlertView

java - 发出发布请求时无法从 jsoup 获取结果

c# - 在注册表中查找应用程序路径

.net - SMPP 服务器和客户端应用程序 C#

c++ - 在 Windows 上使用长 double