Commit 46a34765 authored by liuxinben's avatar liuxinben

去除空行

parent d8dab74c
......@@ -93,6 +93,7 @@ public class ReadExcelApi {
// 如果fileitem中封装的是上传文件
// 得到上传的文件名称
filename = item.getOriginalFilename();
int rows=0;
try {
// 如果fileitem中封装的是普通输入项的数据
// 如果fileitem中封装的是上传文件
......@@ -122,6 +123,7 @@ public class ReadExcelApi {
for (int i = 0; i < list1.size(); i++) {
PersonPostEntity personPostEntity = new PersonPostEntity();
List list2 = (List) list1.get(i);
rows=i;
//跳过空行和第一行
if (list2 == null || i == 0) {
continue;
......@@ -160,7 +162,7 @@ public class ReadExcelApi {
logger.error("", e);
yxresp.outPutError("Exception", "上传文件时发生错误,非法EXCEL文件:" + filename);
map.put("result","false");
map.put("msg","非法EXCEL文件");
map.put("msg","数据格式异常,请检查第 "+rows+" 行数据。");
return map;
}
} catch (Exception e) {
......
......@@ -31,6 +31,39 @@ public class ReadExcel {
// sheet.getRows()返回该页的总行数
for (int i = 0; i < sheet.getRows(); i++) {
List innerList=new ArrayList();
String columns0 = sheet.getCell(0,i).getContents();
String columns1 = sheet.getCell(1,i).getContents();
String columns2 = sheet.getCell(2,i).getContents();
String columns3 = sheet.getCell(3,i).getContents();
String columns4 = sheet.getCell(4,i).getContents();
String columns5 = sheet.getCell(5,i).getContents();
String columns6 = sheet.getCell(6,i).getContents();
String columns7 = sheet.getCell(7,i).getContents();
String columns8 = sheet.getCell(8,i).getContents();
String columns9 = sheet.getCell(9,i).getContents();
String columns10 = sheet.getCell(10,i).getContents();
String columns11 = sheet.getCell(11,i).getContents();
String columns12 = sheet.getCell(12,i).getContents();
String columns13 = sheet.getCell(13,i).getContents();
String columns14 = sheet.getCell(14,i).getContents();
String columns15 = sheet.getCell(15,i).getContents();
String columns16 = sheet.getCell(16,i).getContents();
String columns17 = sheet.getCell(17,i).getContents();
String columns18 = sheet.getCell(18,i).getContents();
String columns19 = sheet.getCell(19,i).getContents();
String columns20 = sheet.getCell(20,i).getContents();
String columns21 = sheet.getCell(21,i).getContents();
String columns22 = sheet.getCell(22,i).getContents();
String columns23 = sheet.getCell(23,i).getContents();
String columns24 = sheet.getCell(24,i).getContents();
if (columns0.equals("")&&columns1.equals("")&&columns2.equals("")&&columns3.equals("")&&
columns4.equals("")&&columns5.equals("")&&columns6.equals("")&&columns7.equals("")&&
columns8.equals("")&&columns9.equals("")&&columns10.equals("")&&columns11.equals("")&&columns12.equals("")&&
columns13.equals("")&&columns14.equals("")&&columns15.equals("")&&columns16.equals("")&&columns17.equals("")&&
columns18.equals("")&&columns19.equals("")&&columns20.equals("")&&columns21.equals("")&&columns22.equals("")&&
columns23.equals("")&&columns24.equals("")){
continue;
}
// sheet.getColumns()返回该页的总列数
for (int j = 0; j < sheet.getColumns(); j++) {
String cellinfo = sheet.getCell(j, i).getContents();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment