DataGrid exported to Excel (with paging)

xiaoxiao2021-04-08  418

Response.contentType = "Application / VND.MS-Excel";

Response.charset = "GB2312";

Response.Appendheader ("Content-Disposition", "Attachment; FileName = Updatedatalog.xls");

Response.contentencoding = system.text.Encoding.utf7; // Set the output stream for Simplified Chinese

THIS.ENABLEVIEWSTATE = false;

System.io.stringWriter SW = new system.io.stringwriter ();

System.Web.ui.htmlTextWriter HW = new system.web.ui.htmlTextWriter (SW);

INT nCur = this.dgrepair.currentpageindex;

Int nsize = this.dgrepair.pagesize;

THIS.DGREPAIR.Allowpaging = false;

THIS.REPAIRBIND ();

This.dgrepair.renderControl (HW);

// The following recovery paging

THIS.DGREPAIR.Allowpaging = true;

THIS.DGREPAIR.CURRENTPAGEINDEX = NCUR;

this.dgrepair.pageSize = nsize;

/ / Re-bound DataGrid

THIS.REPAIRBIND ();

Response.write (SW.TOString ());

Response.end ();

转载请注明原文地址:https://www.9cbs.com/read-132818.html

New Post(0)