Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
midjourney-proxy
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
徐少华
midjourney-proxy
Commits
bfc23157
Commit
bfc23157
authored
Mar 11, 2020
by
1244575290@qq.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分页导出
parent
fab725fb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
19 deletions
+21
-19
ExcelExportor.java
...a/com/pcloud/common/utils/export/excel/ExcelExportor.java
+21
-19
No files found.
pcloud-common/src/main/java/com/pcloud/common/utils/export/excel/ExcelExportor.java
View file @
bfc23157
...
...
@@ -28,6 +28,10 @@ import org.apache.poi.ss.usermodel.HorizontalAlignment;
import
org.apache.poi.ss.usermodel.VerticalAlignment
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.ss.util.CellRangeAddress
;
import
org.apache.poi.xssf.streaming.SXSSFCell
;
import
org.apache.poi.xssf.streaming.SXSSFRow
;
import
org.apache.poi.xssf.streaming.SXSSFSheet
;
import
org.apache.poi.xssf.streaming.SXSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
...
...
@@ -57,6 +61,7 @@ public class ExcelExportor {
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ExcelExportor
.
class
);
private
static
String
excelSuffixName
=
"xls"
;
public
static
HashMap
<
String
,
XSSFWorkbook
>
XSSF_WORK_BOOK_MAP
=
new
HashMap
<
String
,
XSSFWorkbook
>();
public
static
HashMap
<
String
,
SXSSFWorkbook
>
SXSSF_WORK_BOOK_MAP
=
new
HashMap
<>();
/**
* 生成excel
...
...
@@ -99,7 +104,6 @@ public class ExcelExportor {
*
* @author linweibin
* @date 2017年5月22日 下午5:22:38
* @param fileName
* @param dataMap
* @param templateName
* @return
...
...
@@ -235,8 +239,6 @@ public class ExcelExportor {
*
* @author linweibin
* @date 2017年4月19日 下午4:35:58
* @param response
* @param fileName
* @param tempFileName
*/
public
static
String
uploadFile
(
String
tempFileName
)
{
...
...
@@ -265,7 +267,7 @@ public class ExcelExportor {
String
title
=
exportDto
.
getTitle
();
String
[]
rowsName
=
exportDto
.
getRowsName
();
List
<
Object
[]>
dataList
=
exportDto
.
getDataList
();
XSSFWorkbook
workbook
=
getWorkbook
(
title
,
rowsName
,
dataList
,
UID
);
S
XSSFWorkbook
workbook
=
getWorkbook
(
title
,
rowsName
,
dataList
,
UID
);
if
(
exportDto
.
getIsOver
()){
String
tempFilePath
=
UID
+
".xlsx"
;
try
{
...
...
@@ -281,7 +283,7 @@ public class ExcelExportor {
throw
new
ExportException
(
ExportException
.
OPERATE_ERROR
,
"导出Excel失败"
);
}
String
filePath
=
uploadExcel
(
tempFilePath
,
title
);
XSSF_WORK_BOOK_MAP
.
remove
(
UID
);
S
XSSF_WORK_BOOK_MAP
.
remove
(
UID
);
logger
.
info
(
"excel导出成功++++++++++"
+
filePath
);
return
filePath
;
}
...
...
@@ -296,22 +298,22 @@ public class ExcelExportor {
* @param UID
* @throws BizException
*/
private
static
XSSFWorkbook
getWorkbook
(
String
title
,
String
[]
rowsName
,
List
<
Object
[]>
dataList
,
String
UID
)
throws
BizException
{
XSSFWorkbook
workbook
;
logger
.
info
(
"WORK_BOOK_MAP++++++"
+
XSSF_WORK_BOOK_MAP
);
workbook
=
XSSF_WORK_BOOK_MAP
.
get
(
UID
);
XSSF_WORK_BOOK_MAP
.
remove
(
UID
);
private
static
S
XSSFWorkbook
getWorkbook
(
String
title
,
String
[]
rowsName
,
List
<
Object
[]>
dataList
,
String
UID
)
throws
BizException
{
S
XSSFWorkbook
workbook
;
logger
.
info
(
"WORK_BOOK_MAP++++++"
+
S
XSSF_WORK_BOOK_MAP
);
workbook
=
S
XSSF_WORK_BOOK_MAP
.
get
(
UID
);
S
XSSF_WORK_BOOK_MAP
.
remove
(
UID
);
if
(
null
==
workbook
){
// 声明一个工作簿
workbook
=
new
XSSFWorkbook
();
workbook
=
new
S
XSSFWorkbook
();
// 表格列数
int
columnNum
=
rowsName
.
length
;
//设置表头样式
CellStyle
headerStyle
=
getColumnTopStyle
(
workbook
);
//新建sheet
XSSFSheet
sheet
=
workbook
.
createSheet
();
XSSFRow
row
=
null
;
XSSFCell
cell
=
null
;
S
XSSFSheet
sheet
=
workbook
.
createSheet
();
SXSSFRow
row
=
null
;
SXSSFCell
cell
=
null
;
int
rowIndex
=
0
;
//设置标题
row
=
sheet
.
createRow
(
rowIndex
);
...
...
@@ -349,13 +351,13 @@ public class ExcelExportor {
};
}
}
XSSF_WORK_BOOK_MAP
.
put
(
UID
,
workbook
);
SXSSF_WORK_BOOK_MAP
.
put
(
UID
,
workbook
);
}
else
{
XSSFSheet
sheet
=
workbook
.
getSheetAt
(
0
);
S
XSSFSheet
sheet
=
workbook
.
getSheetAt
(
0
);
int
lastRowIndex
=
sheet
.
getLastRowNum
();
logger
.
info
(
"lastRowIndex+++++"
+
lastRowIndex
);
XSSFRow
row
=
null
;
XSSFCell
cell
=
null
;
SXSSFRow
row
=
null
;
SXSSFCell
cell
=
null
;
//设置数据样式
CellStyle
dataStyle
=
getDataStyle
(
workbook
);
dataStyle
.
setAlignment
(
HorizontalAlignment
.
CENTER
);
...
...
@@ -380,7 +382,7 @@ public class ExcelExportor {
};
}
}
XSSF_WORK_BOOK_MAP
.
put
(
UID
,
workbook
);
SXSSF_WORK_BOOK_MAP
.
put
(
UID
,
workbook
);
}
return
workbook
;
}
...
...
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