From 60c3bc8bf17d83e105acfb4b5219643b7aa875f1 Mon Sep 17 00:00:00 2001
From: yl <ykxkd@outlook.com>
Date: 星期一, 26 九月 2022 19:53:03 +0800
Subject: [PATCH] 设备维修申请接口开发
---
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