Commit cc2f3402 by Jbb

excel空白行 导致的数据数据过滤一下

parent 6637bdc3
......@@ -221,10 +221,12 @@ public class TbStLayerDataController {
} else {
errorData.setTimeStr("");
}
pointList.add(errorData);
if(errorData.getxStr() != "" && errorData.getyStr() != "" && errorData.getTitle() != "" && errorData.getTimeStr() != ""){
pointList.add(errorData);
}
}
}
/*XSSFWorkbook wb = new XSSFWorkbook();
/* XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
if(pointList != null && pointList.size() > 0){
//输出流写入到excel中
......@@ -237,32 +239,32 @@ public class TbStLayerDataController {
for (int i = 0; i < pointList.size(); i++) {
TbStLayerData accidentPoint = pointList.get(i);
String title = accidentPoint.getTitle();
Date time = accidentPoint.getTime();
String timeFormat = df.format(time);
String timeStr = accidentPoint.getTimeStr();
//String timeFormat = df.format(time);
XSSFRow rowData = sheet.createRow(i + 1);
rowData.createCell(0).setCellValue(accidentPoint.getxStr());
rowData.createCell(1).setCellValue(accidentPoint.getyStr());
rowData.createCell(2).setCellValue(title);
rowData.createCell(3).setCellValue(timeFormat);
rowData.createCell(3).setCellValue(timeStr);
}
}*/
}
//通过输出流下载
/*response.setContentType("application/vnd.ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=error.xlsx");
outputStream = response.getOutputStream();
ServletOutputStream outputStream = response.getOutputStream();
//设置文件响应输出格式
ByteArrayOutputStream os = new ByteArrayOutputStream();
wb.write(os);
response.reset();
response.setContentType("application/msexcel;charset=utf-8");
bytes = os.toByteArray();
outputStream.write(bytes);
*//*wb.write(outputStream);
// ByteArrayOutputStream os = new ByteArrayOutputStream();
// wb.write(os);
// response.reset();
// response.setContentType("application/msexcel;charset=utf-8");
// bytes = os.toByteArray();
// outputStream.write(bytes);
wb.write(outputStream);
wb.close();
outputStream.flush();
outputStream.close();*//*
flag = true;*/
//return null;
outputStream.close();*/
/*flag = true;*/
//return null;
return pointList;
}
......
......@@ -102,7 +102,7 @@ public class CodeGenerator {
}
@Test
public void testExcel() throws Exception {
InputStream is = new FileInputStream("C:\\Users\\JBB\\Desktop\\工作目录\\excel\\模板.xlsx");
InputStream is = new FileInputStream("C:\\Users\\JBB\\Desktop\\工作目录\\excel\\test.xlsx");
XSSFWorkbook sheets = new XSSFWorkbook(is);
XSSFSheet sheetAt = sheets.getSheetAt(0);
//获取excel有多少行
......@@ -125,7 +125,7 @@ public class CodeGenerator {
String wdStr = "";
String titleStr = "";
String dateStr = "";
if (row.getCell(0) != null && row.getCell(1) != null) {
if (row.getCell(0) != null && !"".equals(row.getCell(0)) && row.getCell(1) != null && !"".equals(row.getCell(0))) {
row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
/*int cellType = row.getCell(0).getCellType();
......
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