asp.net Grid export Excel Implementation Program code _ Practical Skills

Source: Internet
Author: User
1. aspx background code output content type information

Copy Code code as follows:

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> ")


Such implementations are sufficient for simple export of data to Excel.

The usage is very simple
The introduction of the Bootstrap.js and the export-all.js in the compression package will be used
You can refer to Main.js (the following is the definition of grid when specifying a toolbar for xtype: ' Exporterbutton ')

Copy Code code as follows:

HEIGHT:350,
width:600,
Title: ' Array Grid ',
Renderto: ' Grid-example ',
Viewconfig: {
Striperows:true
},
Dockeditems: [
{
Xtype: ' Toolbar ',
Dock: ' Top ',
Items: [
{
Xtype: ' Exporterbutton ',
Store:mystore

Two configurations have been configured in Buttion.js the default path does not need to be repeatedly specified
Swfpath: './downloadify.swf ',
Downloadimage: './download.png ',

Here you can export the file name according to the form
Downloadname: ' Exported Excel name '
}
]
}
]

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.