Examples of DataGrid into Excel

xiaoxiao2021-03-06  84

Response.Clear (); response.buffer = true; response.contenttype = "Application / VND.MS-Excel"; response.charset = ""; this.enableviewState = false;

System.io.stringWriter ostringwriter = new system.io.stringWriter (); system.Web.ui.htmlTextWriter OhtmlTextWriter = new system.web.ui.htmlTextWriter (OstringWriter);

DataGrid DG = New DataGrid (); DG.DataSource = getDataSource (); // Returns DataSet or DataTableDg.Database (); DG.RenderControl (OhtmlTextWriter);

Response.write (ostringwriter.tostring ());

Response.end (); if there is garbled code: response.contentencoding = system.text.encoding.utf8

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

New Post(0)