开发者

Error while generating a PDF file with Excel in ASP.NET

开发者 https://www.devze.com 2022-12-13 21:56 出处:网络
I have to generate an excel file and a PDF file from an asp.net application. I\'m using the Interop assemblies and I can generate the excel file without any problem. But when开发者_运维百科 I\'m gener

I have to generate an excel file and a PDF file from an asp.net application. I'm using the Interop assemblies and I can generate the excel file without any problem. But when开发者_运维百科 I'm generating an pdf file with the add-in SaveAsPDFandXPS.exe I'm getting the next error:

Exception HRESULT: 0x800A03EC

with a debug I see the error is in the next method which is used to export de PDF file:

_objWB.ExportAsFixedFormat(Excel.XlFixedFormatType.xlTypePDF, _nombreArchivo,
   Excel.XlFixedFormatQuality.xlQualityStandard, false, false, Type.Missing,
   Type.Missing, false, Type.Missing);


That might happen when the office version that you developed against is different from the one used at runtime.


You cannot safely use Office Automation in a server process. The Automation APIs are developed for use in a desktop application only. They usually don't work in ASP.NET, or don't work reliably. There are also licensing issues.


Office automation is in general horribly unreliable. Even Microsoft recommend against using it. You might be better off using a pdf generation library like Itextsharp or Crystal Reports.

0

精彩评论

暂无评论...
验证码 换一张
取 消