Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-backend
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AutogeneralShanghai
yd-backend
Commits
e8f49135
Commit
e8f49135
authored
Jul 20, 2020
by
Water Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimzie
parent
78c7896b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
86 deletions
+4
-86
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsStatisticsServiceImpl.java
+4
-86
No files found.
yd-api/src/main/java/com/yd/api/agms/service/impl/AgmsStatisticsServiceImpl.java
View file @
e8f49135
...
@@ -165,13 +165,13 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
...
@@ -165,13 +165,13 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
headerStyle
.
setFillPattern
(
CellStyle
.
SOLID_FOREGROUND
);
headerStyle
.
setFillPattern
(
CellStyle
.
SOLID_FOREGROUND
);
// headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);//居中
// headerStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);//居中
//创建第一行表头
//创建第一行表头
HSSFRow
head
r
ow
=
sheet
.
createRow
(
0
);
HSSFRow
head
R
ow
=
sheet
.
createRow
(
0
);
//遍历添加表头(下面模拟遍历学生,也是同样的操作过程)
//遍历添加表头(下面模拟遍历学生,也是同样的操作过程)
HSSFCell
cell
;
HSSFCell
cell
;
HSSFRichTextString
text
;
HSSFRichTextString
text
;
for
(
int
i
=
0
;
i
<
header
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
header
.
length
;
i
++)
{
//创建一个单元格
//创建一个单元格
cell
=
head
r
ow
.
createCell
(
i
);
cell
=
head
R
ow
.
createCell
(
i
);
//创建一个内容对象
//创建一个内容对象
text
=
new
HSSFRichTextString
(
header
[
i
]);
text
=
new
HSSFRichTextString
(
header
[
i
]);
//将内容对象的文字内容写入到单元格中
//将内容对象的文字内容写入到单元格中
...
@@ -233,6 +233,8 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
...
@@ -233,6 +233,8 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
response
.
setContentType
(
"application/octet-stream"
);
response
.
setContentType
(
"application/octet-stream"
);
//这后面可以设置导出Excel的名称,此例中名为student.xls
//这后面可以设置导出Excel的名称,此例中名为student.xls
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fn
+
".xls"
);
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fn
+
".xls"
);
//下载报表
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
//刷新缓冲
//刷新缓冲
response
.
flushBuffer
();
response
.
flushBuffer
();
//workbook将Excel写入到response的输出流中,供页面下载
//workbook将Excel写入到response的输出流中,供页面下载
...
@@ -240,92 +242,8 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
...
@@ -240,92 +242,8 @@ public class AgmsStatisticsServiceImpl implements AgmsStatisticsService {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
// StringBuilder sbData = new StringBuilder();
// // 组装数据
// if (CollectionUtils.isNotEmpty(resultList)) {
// for (int i = 0; i < resultList.size(); i++) {
// LeadsStatisticsInfo leadsStatisticsData = resultList.get(i);//遍历每个对象
// sbData.append(i + 1).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getRequestSMEDate())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getAssignSMEDate())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getSme())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getSmeMobileNo())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getTalkTime())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getPractitionerName())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getPractitionerMobileNo())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsCreateTime())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsName())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsWeChatId())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsAge())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsGender())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsCity())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsZodiacType())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(leadsStatisticsData.getLeadsBloodTypeId()).append(CSV_COLUMN_SEPARATOR);
// sbData.append(leadsStatisticsData.getPredictFYP()).append(CSV_COLUMN_SEPARATOR);
// sbData.append(leadsStatisticsData.getPredictFYC()).append(CSV_COLUMN_SEPARATOR);
// sbData.append(leadsStatisticsData.getPredictPieces()).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getDealTime())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsSource())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(getDataStr(leadsStatisticsData.getLeadsStatus())).append(CSV_COLUMN_SEPARATOR);
// sbData.append(CSV_ROW_SEPARATOR);
// }
// }
// createCSV(response,tableName,columnName,sbData);
}
}
private
void
createCSV
(
HttpServletResponse
response
,
String
tableName
,
String
[]
columnName
,
StringBuilder
sbData
)
{
String
charset
=
"UTF-8"
;
// 读取字符编码
// 保证线程安全
StringBuilder
buf
=
new
StringBuilder
();
// 组装表头
for
(
String
title
:
columnName
)
{
buf
.
append
(
getDataStr
(
title
)).
append
(
CSV_COLUMN_SEPARATOR
);
}
buf
.
append
(
CSV_ROW_SEPARATOR
);
buf
.
append
(
sbData
);
// 设置文件后缀
String
fn
=
tableName
+
System
.
currentTimeMillis
()
+
".csv"
;
String
headStr
=
"attachment; filename=\""
+
fn
+
"\""
;
// 设置响应
response
.
setContentType
(
"APPLICATION/ms-csv.numberformat"
);
response
.
setCharacterEncoding
(
charset
);
response
.
setHeader
(
"Content-Disposition"
,
headStr
);
response
.
setHeader
(
"Cache-Control"
,
"max-age=30"
);
response
.
setHeader
(
"Access-Control-Expose-Headers"
,
"Content-Disposition"
);
response
.
setHeader
(
"Pragma"
,
"public"
);
// response.setHeader("Content-type", "text/html;charset=GB2312");
OutputStream
os
=
null
;
try
{
os
=
response
.
getOutputStream
();
os
.
write
(
buf
.
toString
().
getBytes
(
"gbk"
));
os
.
flush
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
os
!=
null
){
try
{
os
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
}
private
String
getDataStr
(
String
string
)
{
if
(!
Strings
.
isNullOrEmpty
(
string
)){
return
string
;
// try {
// return new String(string.toString().getBytes("GBK"),"UTF-8");
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
}
return
""
;
}
/**
/**
* 按照条件筛选
* 按照条件筛选
...
...
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