实时报表Excel导出调整为后台导出
This commit is contained in:
@@ -2277,6 +2277,24 @@ public class BaseController {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
ExcelCsv.writeCSVFile(response,titleList,headMap,dataList,fileName,titleTime,msgProp);
|
||||
}
|
||||
|
||||
|
||||
public void _ajaxExport(HttpServletRequest request, HttpServletResponse response,
|
||||
String code,String titleTime,List<String> headerList, List<List<Object>> dataList)
|
||||
throws Exception{
|
||||
Properties msgProp = getMsgProp();
|
||||
String fileName = msgProp.getProperty(code, code) + "_" + DateUtils.getDate("yyyyMMddHHmmss")
|
||||
+ ".xlsx";
|
||||
fileName = fileName.replaceAll(" ", "_");
|
||||
if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0) {
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
} else {
|
||||
fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
|
||||
}
|
||||
new ExportExcel(msgProp.getProperty(code, code),code,titleTime, headerList).ajaxDataList(dataList, code).write(response, fileName).dispose();
|
||||
|
||||
}
|
||||
|
||||
public String initLogMap(BaseLogEntity log,String title){
|
||||
Properties msgProp = getMsgProp();
|
||||
String logTime=msgProp.getProperty(title,title);;
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.nis.web.controller.report;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("${adminPath}/export")
|
||||
public class ExportController extends BaseController {
|
||||
|
||||
@RequestMapping(value = "ajaxExport")
|
||||
public void ajaxExport(String exports,HttpServletRequest request,HttpServletResponse response) throws Exception{
|
||||
JSONObject jsonObject = JSONObject.fromObject(StringEscapeUtils.unescapeHtml(exports));
|
||||
Map<String,Object> map=JSONObject.fromObject(jsonObject);
|
||||
List<List<Object>> list=(List<List<Object>>) map.get("book");
|
||||
List<String> heard=(List<String>) map.get("heard");
|
||||
String titleTime=String.valueOf(map.get("titleTime"));
|
||||
String titleCode=String.valueOf(map.get("titleCode"));
|
||||
_ajaxExport(request,response,titleCode, titleTime, heard, list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user