我在c#中的應用程序有寫入excel表單的概率。 我的應用程序爲其目的創建Excel表,並不寫入它。 下面的代碼僅提供參考..Excel表單打開並迭代寫入
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
}
}
幫助將不勝感激,謝謝提前!
@Akshata:感謝烏拉圭回合的幫助,很新的SOF :) – Sriyad 2011-05-18 06:38:45