【发布时间】:2016-11-21 12:22:15
【问题描述】:
我正在从 GridView 导出到 excel,它在 localhost 上运行良好,但在生产服务器上却不行。我猜服务器上需要安装一些 excel 组件。有谁知道我需要安装什么才能使其正常工作?
GridViewAllApps.DataBind();
Response.Clear();
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=Applications.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridViewAllApps.RenderControl(hw);
string style = @"<style> .textmode {mso-number-format:\@; } </style>";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
【问题讨论】:
-
不知道什么是 GridViewAllApps 类。
-
GridViewAllApps 是我的 DataGrid 的名称