Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sts网站
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
liyang
sts网站
Commits
8dd3ca5b
Commit
8dd3ca5b
authored
Jul 23, 2020
by
soulCoke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
excel 导入数字不需要格式化 ,导入允许列和属性个数不一致。
parent
be778ba3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+14
-10
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
View file @
8dd3ca5b
...
@@ -8,7 +8,6 @@ import java.io.OutputStream;
...
@@ -8,7 +8,6 @@ import java.io.OutputStream;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Comparator
;
import
java.util.Comparator
;
...
@@ -18,6 +17,7 @@ import java.util.List;
...
@@ -18,6 +17,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.UUID
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.hssf.usermodel.HSSFDateUtil
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.BorderStyle
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Cell
;
...
@@ -41,6 +41,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
...
@@ -41,6 +41,7 @@ import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import
org.apache.poi.xssf.usermodel.XSSFDataValidation
;
import
org.apache.poi.xssf.usermodel.XSSFDataValidation
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel.ColumnType
;
import
com.ruoyi.common.annotation.Excel.ColumnType
;
import
com.ruoyi.common.annotation.Excel.Type
;
import
com.ruoyi.common.annotation.Excel.Type
;
...
@@ -200,7 +201,9 @@ public class ExcelUtil<T>
...
@@ -200,7 +201,9 @@ public class ExcelUtil<T>
// 设置类的私有字段属性可访问.
// 设置类的私有字段属性可访问.
field
.
setAccessible
(
true
);
field
.
setAccessible
(
true
);
Integer
column
=
cellMap
.
get
(
attr
.
name
());
Integer
column
=
cellMap
.
get
(
attr
.
name
());
fieldsMap
.
put
(
column
,
field
);
if
(
column
!=
null
)
{
// 字段在excel 中没有,那么就不需要设置值
fieldsMap
.
put
(
column
,
field
);
}
}
}
}
}
for
(
int
i
=
1
;
i
<
rows
;
i
++)
for
(
int
i
=
1
;
i
<
rows
;
i
++)
...
@@ -875,14 +878,15 @@ public class ExcelUtil<T>
...
@@ -875,14 +878,15 @@ public class ExcelUtil<T>
}
}
else
else
{
{
if
((
Double
)
val
%
1
>
0
)
/* if ((Double) val % 1 > 0)
{
{
val
=
new
DecimalFormat
(
"0.00"
).
format
(
val
);
val = new DecimalFormat("0.00").format(val);
}
}
else
else
{
{
val
=
new
DecimalFormat
(
"0"
).
format
(
val
);
val = new DecimalFormat("0").format(val);
}
}*/
val
=
new
BigDecimal
(
val
.
toString
());
// 导入的数据保证原汁原味,不做处理
}
}
}
}
else
if
(
cell
.
getCellTypeEnum
()
==
CellType
.
STRING
)
else
if
(
cell
.
getCellTypeEnum
()
==
CellType
.
STRING
)
...
...
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