1

I have sucessfully exported ExcelWorkBook to PDF using Excel2010 but when I tried same solution on server with Excel 2013 it always throws Exception on ExportAsFixedFormat Method

Here is the Code

object misValue = System.Reflection.Missing.Value;
string paramExportFilePath = @"C:\Test2.pdf";
Excel.XlFixedFormatType paramExportFormat = Excel.XlFixedFormatType.xlTypePDF;
Excel.XlFixedFormatQuality paramExportQuality = Excel.XlFixedFormatQuality.xlQualityStandard;
bool paramOpenAfterPublish = false;
bool paramIncludeDocProps = true;
bool paramIgnorePrintAreas = true;
xlNewWorkBook.ExportAsFixedFormat(paramExportFormat, paramExportFilePath, paramExportQuality, paramIncludeDocProps, paramIgnorePrintAreas, misValue, misValue, paramOpenAfterPublish, misValue);

Here is the Exception:

HRESULT: 0x800A03EC

I tried to use both Office14 and Office15 libraries but same result with both of them

AddyProg
  • 2,960
  • 13
  • 59
  • 110
  • Related: http://stackoverflow.com/questions/7099770/hresult-0x800a03ec-on-worksheet-range http://www.mathworks.com/matlabcentral/answers/101631-why-do-i-receive-an-error-error-code-0x800a03ec-when-using-xlswrite-in-matlab – VMAtm Mar 12 '15 at 12:01
  • Maybe try using the NetOffice API Instead, because the Office InterOp API may have changed between versions. EG: [link](http://stackoverflow.com/questions/23239930/saving-word-document/23240053#23240053) This still uses office InterOp under the hood though! – James S Mar 12 '15 at 12:23

1 Answers1

0

Adil,

Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. You can read more about that in the Considerations for server-side Automation of Office article.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • can you recommend me any free library by using which i can export Excel sheet to PDF? – AddyProg Mar 12 '15 at 12:13
  • Well, I don't think that recommending any commercial components is a good way to go. Try searching the web. For example, take a look at the Aspose components. – Eugene Astafiev Mar 12 '15 at 12:16