|
@@ -3,10 +3,7 @@ package cn.cslg.pas.common.utils;
|
|
|
import cn.cslg.pas.domain.PatentData;
|
|
|
import org.apache.poi.hssf.usermodel.*;
|
|
|
import org.apache.poi.ooxml.POIXMLDocumentPart;
|
|
|
-import org.apache.poi.ss.usermodel.PictureData;
|
|
|
-import org.apache.poi.ss.usermodel.Row;
|
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
|
|
-import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.*;
|
|
|
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -61,9 +58,18 @@ public class ReadExcelUtils {
|
|
|
ThrowException.throwXiaoShiException("文件内容格式不正确,请检查总行数是否有专利内容");
|
|
|
}
|
|
|
|
|
|
+ //获取第一行
|
|
|
Row firstRow = sheet.getRow(0);
|
|
|
- if (!firstRow.getCell(0).getStringCellValue().equals("公开(公告)号")) {
|
|
|
- ThrowException.throwXiaoShiException("文件内容格式不正确,第一列应为【公开(公告)号】");
|
|
|
+ boolean flag = false;
|
|
|
+ //遍历第一行单元格,若第一行有单元格内容是 "公开(公告)号" 则文件合法
|
|
|
+ for (Cell cell : firstRow) {
|
|
|
+ if (cell.getStringCellValue().equals("公开(公告)号")) {
|
|
|
+ flag = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flag) {
|
|
|
+ ThrowException.throwXiaoShiException("文件内容格式不正确,第一行抬头未找到【公开(公告)号】");
|
|
|
}
|
|
|
|
|
|
//返回文件总行数-1(即专利总数量)
|