Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/302.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Excel 2007升级错误_C#_Windows_Winforms_Excel - Fatal编程技术网

C# Excel 2007升级错误

C# Excel 2007升级错误,c#,windows,winforms,excel,C#,Windows,Winforms,Excel,在Windows窗体应用程序中,我将一些数据保存到Excel文件中。 到目前为止,我一直在使用Excel2003并将文件另存为xls。使用此代码: exportFile.SaveAs(strPath, Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlShared, Type.Missing, Type.Mi

在Windows窗体应用程序中,我将一些数据保存到Excel文件中。 到目前为止,我一直在使用Excel2003并将文件另存为xls。使用此代码:

exportFile.SaveAs(strPath, Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
我已经升级到Excel 2007,现在我想将数据保存为xlsx,因此我将同一行更改为:

exportFile.SaveAs(strPath, Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
但是现在,我在那一行得到了一个异常,“来自HRESULT:0x800A03EC的异常” 你知道我做错了什么吗


谢谢大家!

我已经尝试了@david heffernan的解决方案并成功了。
XlSaveAsAccessMode.xlNoChange是否更改了窍门

您是否引用了Excel 2007中的新互操作程序集?是的,我删除了旧的2003引用并添加了2007 What is
XlSaveAsAccessMode.xlShared
全部内容?如果改用
Type.Missing
xlNoChange
会发生什么情况?