Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_beijing_auxiliary_YD
Project
Project
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
zhangyusheng
YX_IDENT_beijing_auxiliary_YD
Commits
46a34765
Commit
46a34765
authored
Mar 27, 2020
by
liuxinben
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除空行
parent
d8dab74c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
1 deletion
+36
-1
ReadExcelApi.java
src/main/java/com/yxproject/start/api/ReadExcelApi.java
+3
-1
ReadExcel.java
src/main/java/com/yxproject/start/utils/ReadExcel.java
+33
-0
No files found.
src/main/java/com/yxproject/start/api/ReadExcelApi.java
View file @
46a34765
...
...
@@ -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
)
{
...
...
src/main/java/com/yxproject/start/utils/ReadExcel.java
View file @
46a34765
...
...
@@ -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
();
...
...
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