Atitit. Exporting the design of Excel----query results export to excel implementation of Java. NET PHP Summary

Source: Internet
Author: User

Atitit. Export The design of Excel----query results to Excel the implementation java. net PHP Summary

1. The main process

Query get list

table reading jsp gets the title and field map

Toexcel (Map,list)

2. The submittedHTMLData Structure

_meth=sql dwr meta-data

_metadata=xxxx

Reqdatas ....

Author :: Old Wow's paw attilax ayron, email:[email protected]

Reprint please indicate source: Http://blog.csdn.net/attilax

3. Handling code

Prj:wechatadm4prp

Command. Reg ("Export", new Closure2 () {

@Override

Public Object Execute (Object arg0) {

Map m2 = Convert2atiormmap (m);

Object SQL  =  New ormx (). Convert2sql (JsonX. toJsonStrO88 (m2));

HBX HBX = Aaacfg.iocx. Getbean (Hbx.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");

list<map> Titlesmap =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<map> titlesmap) {

String FileName =filex. Getuuidname ()+ ". xls" ;

String F =pathx. Webapppath ()+ "\\uploadf\\" + FileName ;

Excelutil. Toexcel (titlesmap, list, F);

return "uploadf/"+fileName;

}

Atitit. Exporting the design of Excel----query results export to excel implementation of Java. NET PHP Summary

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.