Hi,
i got the exception when i am trying to export data to excel.... the exception is
COMException: Exception from HRESULT: 0x800A03EC.
How shall i solve this error? How shall i get solution? Tell me the solution of this problem...
Thanks in advance...
My Code is:
{
oxl = new Excel.Application();
oxl.Visible = true;
oxl.DisplayAlerts = false;
wbook = oxl.Workbooks.Add(Missing.Value);
wsheet = (Excel.Worksheet)wbook.ActiveSheet;
wsheet.Name = "Customers";
DataTable dt = InstituteTypeDetail();
int rowCount = 1;
foreach (DataRow dr in dt.Rows)
{
rowCount += 1;
for (int i = 1; i < dt.Columns.Count + 1; i++)
{
// Add the header the first time through
if (rowCount == 2)
{
wsheet.Cells[1, i] = dt.Columns[i - 1].ColumnName;
}
wsheet.Cells[rowCount, i] = dr[i - 1].ToString();
}
}
range = wsheet.get_Range(wsheet.Cells[1, 1],
wsheet.Cells[rowCount, dt.Columns.Count]);//In this place i got the exception
range.EntireColumn.AutoFit();
wsheet = null;
range = null;
}
what i did wrong? what is the way to solve this exception.... Anyone plz tell me...