日期:2014-05-18  浏览次数:20762 次

未将对象引用设置到对象的实例,关于NPOI
C# code

                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);
                        [color=#FF0000]sheet1.GetRow(row).GetCell(9).SetCellValue(1.0);[/color]
                    }

                }


问题停留在这里,提示未将对象引用设置到对象的实例

------解决方案--------------------
查GetRow(row)返回了null还是GetCell(9)返回了null