asp.net Grid exports the Excel implementation code
- 2020-05-19 04:43:47
- OfStack
1. Aspx background code outputs Content Type information
This implementation is sufficient for the simple export of data to Excel.
The usage is simple
The bootstrap.js and the export-all.js in the compressed package will be available
For details, please refer to main.js (when defining Grid, specify 1 toolbar as xtype: 'exporterbutton')
Response.ClearContent();
Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
Response.ContentType = "application/excel";
Response.Write(GetGridTableHtml(Grid1));
Response.End();2. Direct output Html code
Response.Write(@"
<table border="1">
<tr>
<td>Excel</td>
<td>By Html</td>
</tr>
</table>")
This implementation is sufficient for the simple export of data to Excel.
The usage is simple
The bootstrap.js and the export-all.js in the compressed package will be available
For details, please refer to main.js (when defining Grid, specify 1 toolbar as xtype: 'exporterbutton')
height: 350,
width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
stripeRows: true
},
dockedItems: [
{
xtype: 'toolbar',
dock: 'top',
items: [
{
xtype: 'exporterbutton',
store: myStore
//1 The next two configurations Has been in Buttion.js In the The default path is configured There is no need to repeat the specification
//swfPath: './downloadify.swf',
//downloadImage: './download.png',
// Here you can follow the dang table to Customize the file name of the export
//downloadName:' The exported Excel The name '
}
]
}
]