From 0c9fbd3eb38e5c1ef9e259a79eac9173dce24e22 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期三, 12 十月 2022 09:58:50 +0800
Subject: [PATCH] nothing

---
 VueWebApi/Tools/ImportExcel.cs |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/VueWebApi/Tools/ImportExcel.cs b/VueWebApi/Tools/ImportExcel.cs
index 699a575..f7470ad 100644
--- a/VueWebApi/Tools/ImportExcel.cs
+++ b/VueWebApi/Tools/ImportExcel.cs
@@ -53,6 +53,10 @@
             ISheet sheet = Workbook.GetSheetAt(0);
             //绗竴琛屼负鏍囬琛�
             IRow headerRow = sheet.GetRow(0);
+            if (headerRow == null)
+            {
+                return table;
+            }
             int cellCount = headerRow.LastCellNum;
             int rowCount = sheet.LastRowNum;
 
@@ -68,7 +72,7 @@
             {
                 IRow row = sheet.GetRow(i);
                 DataRow dataRow = table.NewRow();
-                if (row != null)
+                if (row != null&&row.Cells.Count>0)
                 {
                     for (int j = row.FirstCellNum; j < cellCount; j++)
                     {
@@ -146,6 +150,10 @@
                 ISheet sheet = Workbook.GetSheetAt(0);
                 //绗竴琛屼负鏍囬琛�
                 IRow headerRow = sheet.GetRow(0);
+                if (headerRow == null) 
+                {
+                   return list;
+                }
                 int cellCount = headerRow.LastCellNum;
                 int rowCount = sheet.LastRowNum;
 
@@ -161,7 +169,7 @@
                 {
                     IRow row = sheet.GetRow(i);
                     DataRow dataRow = table.NewRow();
-                    if (row != null)
+                    if (row != null&&row.Cells.Count>0)
                     {
                         for (int j = row.FirstCellNum; j < cellCount; j++)
                         {
@@ -198,13 +206,17 @@
             }
             else
             {
-                for (int m = 0; m < 2; m++)
+                for (int m = 0; m < count; m++)
                 {
                     DataTable table = new DataTable();
                     //瀹氫綅鍦ㄧ涓�涓猻heet
                     ISheet sheet = Workbook.GetSheetAt(m);
                     //绗竴琛屼负鏍囬琛�
                     IRow headerRow = sheet.GetRow(0);
+                    if (headerRow == null)
+                    {
+                        return list;
+                    }
                     int cellCount = headerRow.LastCellNum;
                     int rowCount = sheet.LastRowNum;
 
@@ -220,7 +232,7 @@
                     {
                         IRow row = sheet.GetRow(i);
                         DataRow dataRow = table.NewRow();
-                        if (row != null)
+                        if (row != null&&row.Cells.Count>0)
                         {
                             for (int j = row.FirstCellNum; j < cellCount; j++)
                             {

--
Gitblit v1.9.3