Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
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
WitCloud
TDLCloud
Commits
a89d1f4b
Commit
a89d1f4b
authored
Dec 21, 2020
by
Carit Zhu
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 1.0.2:
1. Modify excel generator to use the year of first data instead of permanent 2018.
parent
13f9be95
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
build.gradle
build.gradle
+1
-1
WarehouseExcel.java
src/main/java/com/example/tdl/common/WarehouseExcel.java
+13
-8
No files found.
build.gradle
View file @
a89d1f4b
...
...
@@ -15,7 +15,7 @@ apply plugin: 'idea'
apply
plugin:
'org.springframework.boot'
group
=
'com.example'
version
=
'1.0.
1
-release'
version
=
'1.0.
2
-release'
sourceCompatibility
=
1.8
repositories
{
...
...
src/main/java/com/example/tdl/common/WarehouseExcel.java
View file @
a89d1f4b
...
...
@@ -53,6 +53,7 @@ public class WarehouseExcel {
public
HSSFWorkbook
downloadExcel
()
throws
Exception
{
// 创建工作簿对象
HSSFWorkbook
workbook
=
new
HSSFWorkbook
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd-HH-mm-ss"
);
try
{
HSSFSheet
sheet
=
workbook
.
createSheet
(
fileName
);
// 创建工作表
HSSFCellStyle
style
=
getStyle
(
workbook
);
...
...
@@ -89,16 +90,21 @@ public class WarehouseExcel {
/*
* 创建第二行
* */
String
year
=
""
;
if
(!
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
isEmpty
()){
long
timestamp
=
Long
.
parseLong
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
get
(
0
).
getTime
());
String
dateTime
=
sdf
.
format
(
new
Date
(
timestamp
));
year
=
dateTime
.
split
(
"-"
)[
0
];
// Use the year of first data.
}
HSSFRow
row2
=
sheet
.
createRow
((
short
)
rowCount
);
HSSFCell
cell2
=
null
;
HSSFCell
cell2
=
row2
.
createCell
(
0
)
;
HSSFCellStyle
rowStyle2
=
getStyle
(
workbook
);
cell2
=
row2
.
createCell
(
0
);
for
(
int
n
=
0
;
n
<
3
;
n
++)
{
cell2
=
row2
.
createCell
(
n
);
//设置列的格式
cell2
.
setCellStyle
(
rowStyle2
);
//将标题添加到列中
cell2
.
setCellValue
(
i18n
.
getMessage
(
request
,
"year"
)+
":
2018"
);
cell2
.
setCellValue
(
i18n
.
getMessage
(
request
,
"year"
)+
":
"
+
year
);
}
sheet
.
addMergedRegion
(
new
CellRangeAddress
(
1
,
1
,
0
,
2
));
for
(
int
n
=
3
;
n
<
6
;
n
++)
{
...
...
@@ -201,11 +207,10 @@ public class WarehouseExcel {
for
(
int
i
=
0
;
i
<
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
size
();
i
++)
{
HSSFRow
row
=
sheet
.
createRow
((
short
)
rowCount
+
i
);
HSSFCell
cell
=
null
;
Long
seconds
=
Long
.
valueOf
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
get
(
i
).
getTime
());
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd-HH-mm-ss"
);
String
time
=
sdf
.
format
(
new
Date
(
seconds
));
String
[]
t
=
sdf
.
format
(
new
Date
(
seconds
)).
split
(
"-"
);
long
timestamp
=
Long
.
parseLong
(
resultWarehouseNoAndTDLSNAndTimeVo
.
getDownloadWarehouseVos
().
get
(
i
).
getTime
());
//SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
String
dateTime
=
sdf
.
format
(
new
Date
(
timestamp
));
String
[]
t
=
dateTime
.
split
(
"-"
);
cell2
=
row2
.
createCell
(
1
);
cell2
.
setCellValue
(
t
[
0
]);
cell2
.
setCellStyle
(
rowStyle
);
...
...
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