Atitit. export the excel design query results to the excel implementation java. netphp summary

Source: Internet
Author: User
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;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.