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
131b8ff9
Commit
131b8ff9
authored
Apr 23, 2019
by
dahai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
c7bd42f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
24 deletions
+25
-24
ExportExcelApi.java
src/main/java/com/yxproject/start/api/ExportExcelApi.java
+25
-24
No files found.
src/main/java/com/yxproject/start/api/ExportExcelApi.java
View file @
131b8ff9
...
...
@@ -62,36 +62,37 @@ public class ExportExcelApi {
* 导出交接单
*/
@RequestMapping
(
"printReceiptExcelData"
)
public
byte
[]
printReceiptExcelData
(
@RequestBody
String
list
,
HttpServletResponse
response
)
{
public
List
<
Map
<
String
,
Object
>>
printReceiptExcelData
(
@RequestBody
String
list
,
HttpServletResponse
response
)
{
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
list
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
jsonObject
.
get
(
"list"
));
String
startDate
=
jsonObject
.
get
(
"startDate"
).
toString
();
String
endDate
=
jsonObject
.
get
(
"endDate"
).
toString
();
String
type
=
jsonObject
.
get
(
"type"
).
toString
();
List
<
Map
<
String
,
Object
>>
mapList
=
receiptService
.
selectReceiptList
(
jsonArray
,
replaceDate
(
startDate
),
replaceDate
(
endDate
),
Long
.
valueOf
(
type
));
response
.
setContentType
(
"application/x-download"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
dateTime
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyy_MM_dd"
);
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String
fout
=
null
;
fout
=
ExportExcel
.
exportReceiptExcelDate
(
mapList
);
String
outFile
=
dateTime
+
""
;
try
{
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
fout
));
byte
[]
b
=
new
byte
[
fis
.
available
()];
fis
.
read
(
b
);
fis
.
close
();
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"application/octet-stream"
);
response
.
addHeader
(
"Content-Disposition"
,
"attachment;"
+
new
String
(
outFile
.
getBytes
(),
"iso-8859-1"
)
+
".xls"
);
return
b
;
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
// response.setContentType("application/x-download");
// response.setCharacterEncoding("UTF-8");
// String dateTime = DateFormatUtils.format(new Date(), "yyyy_MM_dd");
//// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
// String fout = null;
// fout = ExportExcel.exportReceiptExcelDate(mapList);
// String outFile = dateTime + "";
//
// try {
// FileInputStream fis = new FileInputStream(new File(fout));
// byte[] b = new byte[fis.available()];
// fis.read(b);
// fis.close();
// response.setCharacterEncoding("utf-8");
// response.setContentType("application/octet-stream");
// response.addHeader("Content-Disposition", "attachment;" + new String(outFile.getBytes(), "iso-8859-1") + ".xls");
// return b;
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// } catch (IOException e) {
// e.printStackTrace();
// }
// return null;
return
mapList
;
}
...
...
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