代码如下: 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(); //返回DataSet或DataTabledg.DataBind();dg.RenderControl(oHtmlTextWriter);Response.Write(oStringWriter.ToString());Response.End(); 相关文章: 2021-12-29 2022-12-23 2022-12-23 2021-10-08 2021-11-05 2021-09-26 2022-12-23 2022-12-23