1. Aspx background code outputs Content Type information
Copy codeThe Code is as follows: 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 ')
Copy codeThe Code is as follows: 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'
}
]
}
]