string dim = convert.isNull(sheet1.GetRow(row).GetCell(2)); if (dim == "1" || dim == "3")
{
string RKBIT1 = convert.isNull(sheet1.GetRow(row).GetCell(5).ToString().Trim());
string RKBIT2 = convert.isNull(sheet1.GetRow(row).GetCell(6));
string data = convert.isNull(sheet1.GetRow(row).GetCell(2).ToString().Trim());
string fangxiang = convert.isNull(sheet1.GetRow(row).GetCell(3).ToString().Trim());
string BAKEY = convert.isNull(sheet1.GetRow(row).GetCell(4).ToString().Trim());
string value = get_per_database(RKBIT1, RKBIT2, STIME, ETIME, data, fangxiang, BAKEY);
double newvalue = convert.StrTodouble(value);
if (newvalue != 0)
{
//sheet1.GetRow(row).GetCell(9).SetCellValue(newvalue);
sheet1.GetRow(row).GetCell(9).SetCellValue(1.0);
} }问题停留在这里,提示未将对象引用设置到对象的实例
问题停留在这里
两个都不是null呢,我就是奇怪,我其他程序都是这个方法,唯独这个时候不行。
我知道其中的原因,就是
sheet1.GetRow(row).GetCell(9).SetCellValue(1),的确这格GetCell(9)是null,但是我这个是赋值不是取值,为什么还判断其中是否未null,请问两位老鸟该怎么处理?
实例下,或者检查下为什么为null
是不是要新加入一个第九格?看你的代码像操作excel,可你又说 sheet1是 string类型我假象的代码如下,如果你那又类似的函数,试试吧 sheet1.GetRow(row).InsertCell(9)
sheet1.GetRow(row).GetCell(9).SetCellValue(1)