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);
                    }                }问题停留在这里,提示未将对象引用设置到对象的实例

解决方案 »

  1.   

    sheet1.GetRow(row).GetCell(9).SetCellValue(1.0);
    问题停留在这里
      

  2.   

    查GetRow(row)返回了null还是GetCell(9)返回了null
      

  3.   


    两个都不是null呢,我就是奇怪,我其他程序都是这个方法,唯独这个时候不行。
      

  4.   

    string,是表示excel中的表名
    我知道其中的原因,就是
    sheet1.GetRow(row).GetCell(9).SetCellValue(1),的确这格GetCell(9)是null,但是我这个是赋值不是取值,为什么还判断其中是否未null,请问两位老鸟该怎么处理?
      

  5.   

    eg:null.setvalue(); 会报错,不可能去操作一个null.setvalue();
    实例下,或者检查下为什么为null
      

  6.   

    lz 说了,因为没有第九格GetCell(9)所以报错
    是不是要新加入一个第九格?看你的代码像操作excel,可你又说 sheet1是 string类型我假象的代码如下,如果你那又类似的函数,试试吧 sheet1.GetRow(row).InsertCell(9)
    sheet1.GetRow(row).GetCell(9).SetCellValue(1)