Export Excel Code from Grid

Source: Internet
Author: User

This article briefly introduces how to export the Excel Code from Grid. For more information, see.

After reading the FineUI Implementation Method for exporting Grid to Excel, it is actually very simple. It seems that it is very difficult to change one idea.

1. Aspx background code outputs Content Type information

The Code is as follows: Copy code

Response. ClearContent ();
Response. AddHeader ("content-disposition", "attachment; filename=MyExcelFile.xls ");
Response. ContentType = "application/excel ";
Response. Write (GetGridTableHtml (Grid1 ));
Response. End (); 2. Directly output Html code
Response. Write (@"
<Table border = "1">
<Tr>
<Td> Excel </td>
<Td> By Html </td>
</Tr>
</Table> ")

This implementation is sufficient for simply exporting data to Excel.

Easy to use

 
The introduction of bootstrap. js and the export-all.js In the compressed package can be used.

 
For details, refer to main. js (the following is to specify a toolbar as xtype: 'exporterclick' when defining the Grid ')

The Code is as follows: Copy code

Height: 350,
Width: 600,
Title: 'array grid ',
RenderTo: 'grid-example ',
ViewConfig :{
StripeRows: true
},
DockedItems :[
{
Xtype: 'toolbar ',
Dock: 'top ',
Items :[
{
Xtype: 'exporterclick ',
Store: myStore

// The following two configurations have been configured in Buttion. js. The default path does not need to be specified repeatedly.
// SwfPath: './downloadify.swf ',
// DownloadImage: './download.png ',

// Here you can customize the exported file name based on the table.
// DownloadName: 'exported Excel name'
}
]
}
]

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.