网页中Table保存为Excel问题 excel导出保存 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 同问,我还想知道怎么把excel里的东西读出来 你可以在table中插入标题行 然后把表格以excel的方式输出出来粘上导出代码: public void ResponseData(DataTable o, String FileName) { GridView dgExport = null; HttpContext curContext = HttpContext.Current; System.IO.StringWriter strWriter = null; HtmlTextWriter htmlWriter = null; if (o != null) { if (Request.Browser.Browser == "IE") { FileName = System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.GetEncoding("UTF-8")); } Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".xls"); Response.ContentType = "application nd.ms-excel"; Response.ContentEncoding = System.Text.Encoding.Default; Response.Charset = "GB2312"; strWriter = new System.IO.StringWriter(); htmlWriter = new HtmlTextWriter(strWriter); dgExport = new GridView(); dgExport.DataSource = o; dgExport.AllowPaging = false; dgExport.DataBind(); dgExport.RenderControl(htmlWriter); Response.Write(strWriter.ToString()); Response.End(); } } 可能是我没说清楚,我要保存的是网页上的一个<table></table>没有dateTable参数可以传送,是不是能通过<table></table>的id或者别的方法保存这个表格到excel 用NPOI工具类,网上搜下,或者直接把Excel当作一个数据库来操作。读写都可以解决了。 控件拖动问题,拖动中进行排序. 模糊查询的问题 用JS 怎么限制用户输入的时候 只能输入汉字,切只能是7位以下的数字呢? 串口通讯中的定时保存串口数据问题?我用的是serialport类. C# XML序列化的Timed Out异常 datagridview和上下文菜单的问题 关于C#连接mysql数据库出乱码的问题 c#中如何异步触发对象的事件? SOCKET通信,接收数据分段。 一个简单的变异错误! C# Excel导入导出卡死问题 c# 异步调用 与 多线程是怎么一回事呢 有联系么 还是都是实现线程的一种方法
{
GridView dgExport = null;
HttpContext curContext = HttpContext.Current;
System.IO.StringWriter strWriter = null;
HtmlTextWriter htmlWriter = null;
if (o != null)
{
if (Request.Browser.Browser == "IE")
{
FileName = System.Web.HttpUtility.UrlEncode(FileName, System.Text.Encoding.GetEncoding("UTF-8"));
}
Response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".xls");
Response.ContentType = "application nd.ms-excel";
Response.ContentEncoding = System.Text.Encoding.Default;
Response.Charset = "GB2312";
strWriter = new System.IO.StringWriter();
htmlWriter = new HtmlTextWriter(strWriter);
dgExport = new GridView();
dgExport.DataSource = o;
dgExport.AllowPaging = false;
dgExport.DataBind();
dgExport.RenderControl(htmlWriter); Response.Write(strWriter.ToString());
Response.End();
} }