Commit 131b8ff9 authored by dahai's avatar dahai

push

parent c7bd42f0
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment