Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
map-parent
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
常超
map-parent
Commits
cc2f3402
Commit
cc2f3402
authored
Jul 13, 2021
by
Jbb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel空白行 导致的数据数据过滤一下
parent
6637bdc3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
20 deletions
+22
-20
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
+20
-18
service/view/src/test/java/com/founder/demo/CodeGenerator.java
+2
-2
No files found.
service/view/src/main/java/com/founder/view/controller/TbStLayerDataController.java
View file @
cc2f3402
...
@@ -221,10 +221,12 @@ public class TbStLayerDataController {
...
@@ -221,10 +221,12 @@ public class TbStLayerDataController {
}
else
{
}
else
{
errorData
.
setTimeStr
(
""
);
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();
XSSFSheet sheet = wb.createSheet();
if(pointList != null && pointList.size() > 0){
if(pointList != null && pointList.size() > 0){
//输出流写入到excel中
//输出流写入到excel中
...
@@ -237,32 +239,32 @@ public class TbStLayerDataController {
...
@@ -237,32 +239,32 @@ public class TbStLayerDataController {
for (int i = 0; i < pointList.size(); i++) {
for (int i = 0; i < pointList.size(); i++) {
TbStLayerData accidentPoint = pointList.get(i);
TbStLayerData accidentPoint = pointList.get(i);
String title = accidentPoint.getTitle();
String title = accidentPoint.getTitle();
Date time = accidentPoint.getTime
();
String timeStr = accidentPoint.getTimeStr
();
String timeFormat = df.format(time);
//
String timeFormat = df.format(time);
XSSFRow rowData = sheet.createRow(i + 1);
XSSFRow rowData = sheet.createRow(i + 1);
rowData.createCell(0).setCellValue(accidentPoint.getxStr());
rowData.createCell(0).setCellValue(accidentPoint.getxStr());
rowData.createCell(1).setCellValue(accidentPoint.getyStr());
rowData.createCell(1).setCellValue(accidentPoint.getyStr());
rowData.createCell(2).setCellValue(title);
rowData.createCell(2).setCellValue(title);
rowData.createCell(3).setCellValue(time
Format
);
rowData.createCell(3).setCellValue(time
Str
);
}
}
}
*/
}
//通过输出流下载
//通过输出流下载
/*
response.setContentType("application/vnd.ms-excel");
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment;filename=error.xlsx");
response.setHeader("Content-Disposition", "attachment;filename=error.xlsx");
outputStream = response.getOutputStream();
ServletOutputStream
outputStream = response.getOutputStream();
//设置文件响应输出格式
//设置文件响应输出格式
ByteArrayOutputStream os = new ByteArrayOutputStream();
//
ByteArrayOutputStream os = new ByteArrayOutputStream();
wb.write(os);
//
wb.write(os);
response.reset();
//
response.reset();
response.setContentType("application/msexcel;charset=utf-8");
//
response.setContentType("application/msexcel;charset=utf-8");
bytes = os.toByteArray();
//
bytes = os.toByteArray();
outputStream.write(bytes);
//
outputStream.write(bytes);
*//*
wb.write(outputStream);
wb.write(outputStream);
wb.close();
wb.close();
outputStream.flush();
outputStream.flush();
outputStream.close();*/
/*
outputStream.close();*/
flag = true;*/
/*
flag = true;*/
//return null;
//return null;
return
pointList
;
return
pointList
;
}
}
...
...
service/view/src/test/java/com/founder/demo/CodeGenerator.java
View file @
cc2f3402
...
@@ -102,7 +102,7 @@ public class CodeGenerator {
...
@@ -102,7 +102,7 @@ public class CodeGenerator {
}
}
@Test
@Test
public
void
testExcel
()
throws
Exception
{
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
);
XSSFWorkbook
sheets
=
new
XSSFWorkbook
(
is
);
XSSFSheet
sheetAt
=
sheets
.
getSheetAt
(
0
);
XSSFSheet
sheetAt
=
sheets
.
getSheetAt
(
0
);
//获取excel有多少行
//获取excel有多少行
...
@@ -125,7 +125,7 @@ public class CodeGenerator {
...
@@ -125,7 +125,7 @@ public class CodeGenerator {
String
wdStr
=
""
;
String
wdStr
=
""
;
String
titleStr
=
""
;
String
titleStr
=
""
;
String
dateStr
=
""
;
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
(
0
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
row
.
getCell
(
1
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
row
.
getCell
(
1
).
setCellType
(
Cell
.
CELL_TYPE_STRING
);
/*int cellType = row.getCell(0).getCellType();
/*int cellType = row.getCell(0).getCellType();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment