Browse Source

NPOI读取数据报错

zhengbingbing 6 years ago
parent
commit
4804e31653
1 changed files with 8 additions and 5 deletions
  1. 8 5
      codegit/CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

+ 8 - 5
codegit/CallCenterCommon/CallCenter.Utility/NPOI/NPOIHelper.cs

@@ -422,15 +422,18 @@ namespace CallCenter.Utility
422 422
                 DataRow dr = dt.NewRow();
423 423
 
424 424
                 IRow row = sheet.GetRow(i);
425
-                for (int j = row.FirstCellNum; j < cellCount; j++)
425
+                if (row != null)
426 426
                 {
427
-                    if (row.GetCell(j) != null)
427
+                    for (int j = row.FirstCellNum; j < cellCount; j++)
428 428
                     {
429
-                        dr[j] = row.GetCell(j).ToString();
429
+                        if (row.GetCell(j) != null)
430
+                        {
431
+                            dr[j] = row.GetCell(j).ToString();
432
+                        }
430 433
                     }
431
-                }
432 434
 
433
-                dt.Rows.Add(dr);
435
+                    dt.Rows.Add(dr);
436
+                }
434 437
             }
435 438
 
436 439
             sheet = null;