Alternatives to Excel Interop SaveAs() method

We are using excel interop to create excel reports in a windows service. Everything works fine in Windows 7 OS. But when the service is deployed in Win2K8R2 server, observed that following exception is thrown while saving the excel document using "SaveAs()" method.

Exception - HRESULT: 0x800A03EC

After researching got to know that, we need to use "SaveCopyAs()" or use "Close()" instead of SaveAs() method. I tried using "SaveCopyAs()" method and found out that excel report creation works fine but "Excel.exe" in task manager remains. This is a memory leak problem.

Hence used "Close(true, filename, false)" method and everything works fine, which includes clearing "Excel.exe" process in task manager.

A common mechanism is considered for disposing the COM objects, by assigning the objects to null after usage for both scenarios tested.

Now, I'm confused with the right approach to take it forward. Please clarify.


Look at Open XML SDK
Microsoft does not recommend Office Interopt for server automation

How to: Create a spreadsheet document by providing a file name (Open XML SDK)

There are also commercial packages like Aspose

And free packages such as EPPlus.


tried using "SaveCopyAs()" method and found out that excel report creation works fine but "Excel.exe" in task manager remains.

--> This is probably because your workbook is not closed.

--> use Marshal.ReleaseComObject() method before assigning null to excel objects.

链接地址: http://www.djcxy.com/p/35652.html

上一篇: 需要澄清答案正确清理Excel互操作对象

下一篇: Excel Interop SaveAs()方法的替代方法