views:

156

answers:

4

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);
+1  A: 

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

MArag
A: 

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.

fearofawhackplanet
A: 

This library: "Excel to PDF .Net" will be helpful to export xls to pdf without MS Office automation.

SautinSoft.XlsToPdf x = new SautinSoft.XlsToPdf();
x.OutputFormat = SautinSoft.XlsToPdf.eOutputFormat.Pdf;
x.ConvertFile(@"d:\Workbook.xls", @"d:\Hardcopy.pdf");
Maximus
+1  A: 

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.

John Saunders