Atitit. Exporting Excel Design Query results export to excel implementation of Java. NET PHP Summary

Source: Internet
Author: User
Atitit. Exporting the design of Excel----query results export to excel implementation of Java. NET PHP Summary

1. The main process

Query Get list

Table reading JSP gets the title and field map

Toexcel (Map,list)

2. Submitted HTML data structure

_meth=sql DWR meta-data

_metadata=xxxx

Reqdatas ....

Author:: Old Wow's paw Attilax Ayron, email:1466519819@qq.com

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 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 titlesmap) {

String filename=filex.getuuidname () + ". xls";

String F=pathx.webapppath () + "\\uploadf\\" +filename;

Excelutil.toexcel (Titlesmap, List, f);

Return "uploadf/" +filename;

}

  • Related Article

    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.