C# System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC Microsoft.Office.Interop.Excel._Workbook.SaveAs()

cexcelwindows

I'm having issues with saving an excel spreadsheet when running on the Windows server 2008 and 2012 but this project its working on local pc (Windows 7,8 or 10)

C# source code

Microsoft.Office.Interop.Excel.Application excelApp = new Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook excelWorkBook = excelApp.Workbooks.Add();
Microsoft.Office.Interop.Excel.Worksheet excelWorkSheet = excelWorkBook.Worksheets.Add();
excelWorkSheet.Name = "blablabla";
//added cells data
excelWorkBook.SaveAs(excelPath.ToString());
excelWorkBook.Close();
excelApp.Quit();

error message

Exception from HRESULT: 0x800A03EC
System.Runtime.InteropServices.COMException (0x800A03EC): Exception
from HRESULT: 0x800A03EC at
Microsoft.Office.Interop.Excel._Workbook.SaveAs(Object Filename,
Object FileFormat, Object Password, Object WriteResPassword, Object
ReadOnlyRecommended, Object CreateBackup, XlSaveAsAccessMode
AccessMode, Object ConflictResolution, Object AddToMru, Object
TextCodepage, Object TextVisualLayout, Object Local)

Best Answer

Installing MS office in servers to run office.interop assemblies in u r project is the best option..

Again if u don't want to install MS office at all on server machine, Then u can install PIA (primary interop assemblies)

http://msdn.microsoft.com/en-us/library/kh3965hw.aspx

download link for PIA for office

http://www.microsoft.com/downloads/details.aspx?FamilyID=59daebaa-bed4-4282-a28c-b864d8bfa513&DisplayLang=en

Related Topic