my app in c# has a prob in writing to excel sheet.
My app create excel sheet for its purpose and does not write in it.
the below code is for reference only..
class a
{
void m()
{
b bee=new b();
Excel.Application oXL;
Excel._Workbook oWB;
b.write(oXL,oWB); //will be called multiple times
}
}
class b
{
static b() //declared static so that only once excel workbook with sheets will be created
{
Excel._Application oXL = new Excel.Application();
Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add(Type.Missing));
}
write( Excel.Application oXL, Excel._Workbook oWB)
{
oXL.Visible = true; //Here its throwing, Object reference not set to an instance of an
//Object
}
}
Help will be appreciated, thanks in advance!
I think you want to have code along the lines of the following:
You then need to make sure, that you create only as many instances of
aas you want Excel sheets.You can use it like this: