我在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