Hi All,
In one the intranet sites which I have developed, im creating an excel file from C#.Net 2005-ASP.NET 2.0
application. In my local machine which runs on Windows XP the application works perfectly, but when I try to run
the application in windows 2008 server machine it throws an exception.
Exception from HRESULT: 0x800A03EC
What is running in the windows 2008 server machine is the published version of my application. I have all the
required dlls and other application dependency files in the bin folder including Interop.Excel.dll and
Interop.Microsoft.Office.Core.dll.
The windows 2008 server machine has MS Office 2003 version installed. I have also configured DCOM in this machine.
Here is my code
"Exception from HRESULT: 0x800A03EC" exception is thrown when the line of code
xlWorkBook.SaveAs((object)(fileName), objMissing, objMissing, objMissing, objMissing, objMissing, Excel.XlSaveAsAccessMode.xlNoChange, objMissing, objMissing, objMissing, objMissing, objMissing); is executed.
Looking forward to hear from you soon.
In one the intranet sites which I have developed, im creating an excel file from C#.Net 2005-ASP.NET 2.0
application. In my local machine which runs on Windows XP the application works perfectly, but when I try to run
the application in windows 2008 server machine it throws an exception.
Exception from HRESULT: 0x800A03EC
What is running in the windows 2008 server machine is the published version of my application. I have all the
required dlls and other application dependency files in the bin folder including Interop.Excel.dll and
Interop.Microsoft.Office.Core.dll.
The windows 2008 server machine has MS Office 2003 version installed. I have also configured DCOM in this machine.
Here is my code
C#:
string fileName = "", strSaveFileAs = "";//To Save the File Name of the Excel File
ItemMaster itemInfo;
Excel.Application xlApp = new Excel.Application();//initialise Xl app
Excel.Workbook xlWorkBook = xlApp.Workbooks.Add(true);
object worksheet = xlWorkBook.ActiveSheet;// set work sheet
object objMissing = System.Reflection.Missing.Value;
if (arList.Count > 0)
{
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1,1] = "SINO";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 2] = "ItemGroupName";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 3] = "ItemCode";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 4] = "ItemName";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 5] = "QTY";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[1, 6] = "Rate";
int SINo = 0;// To Show Serial No in excel.
for (int iRows = 1; iRows <= arList.Count; iRows++)
{
itemInfo = new ItemMaster();
itemInfo = (ItemMaster)arList[SINo];
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 1] = (SINo + 1).ToString();
//Here GroupId actually contains group name
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 2] = itemInfo.GroupID.ToString();
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 3] = itemInfo.ItemCode.ToString();
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 4] = itemInfo.ItemName.ToString();
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 5] = "";
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 6] = itemInfo.Rate.ToString();
((Excel.Worksheet)xlApp.ActiveSheet).Cells[iRows + 1, 7] = "";
((Excel.Worksheet)worksheet).Columns.AutoFit(); //format
xlApp.ScreenUpdating = true;
SINo++;
}
/* FileName format of xls is: QuoteNo_CustomerName_Date*/
strSaveFileAs = txtCode.Text + "_" + ddlCustomer.SelectedItem.ToString() + "_" + txtDate.Text;
string filePath = Server.MapPath("..//Sales//Quote/");
fileName = filePath + "QuoteFile" + ".xls";
if (File.Exists(fileName))
File.Delete(fileName);
//Save file in the Location fileName
xlWorkBook.SaveAs((object)(fileName), objMissing, objMissing, objMissing, objMissing, objMissing,
Excel.XlSaveAsAccessMode.xlNoChange, objMissing, objMissing, objMissing, objMissing, objMissing);
xlWorkBook.SaveAs((object)(fileName), objMissing, objMissing, objMissing, objMissing, objMissing, Excel.XlSaveAsAccessMode.xlNoChange, objMissing, objMissing, objMissing, objMissing, objMissing); is executed.
Looking forward to hear from you soon.
Last edited by a moderator: