Atitit. export excel design query results export to excel implementation java. netphp summary atitit. export excel design ---- query results export to excel implementation java. net php summary
1. main process
Query to obtain the list
Read the table of jsp to obtain the map of the title and field.
Toexcel (map, list)
2. submitted html data structure
_ Meth = metadata of SQL dwr
_ Metadata = xxxx
ReqDatas ....
Author: old Wow's paw Attilax iron, EMAIL: 1466519819@qq.com
3. process code
Prj: wechatadm4upa
Command. reg ("export", new Closure2 (){
@ Override
Public Object execute (Object arg0 ){
Map m2 = convert2atiormMap (m );
Object SQL = new OrmX (). convert2sql (JsonX. toJsonStrO88 (m2 ));
X-ray = AaaCfg. IocX. getBean (X-ray. class );
Try {
List li = hbx.exe (SQL );
Map m3 = new HashMap ();
M3.put ("size", li. size ());
JSONObject metadata = JSONObject. fromObject (m. get ("_ metadata "));
String jsppath = metadata. getString ("titleMapFile ");
ListTitlesMap = HtmlX. getTitlesMap (jsppath, "tabid1", "UTF-8 ");
M3.put ("url", geneExportExcel (li, titlesMap ));
Return m3;
} Catch (SQLGrammarException e ){
Filex. saveLog (SQL. toString (), "c: \ e ");
Throw new RuntimeException (SQL. toString (), e );
}
// Return s;
}
});
Protected Object geneExportExcel (List list List, ListTitlesMap ){
String fileName = filex. getUUidName () + ". xls ";
String f = pathx. webAppPath () + "\ uploadf \" + fileName;
ExcelUtil. toExcel (titlesMap, list, f );
Return "uploadf/" + fileName;
}