关于ASP.NET导出Excel的问题 asp.netexcelC# 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你到底是导入还是导出???但是不管导入还是导出 都i建议使用第三方组件,比如 myxls nopi and so on ...具体的请自行百度 在服务器端用OLEDB的方式写入EXCEL,再使用RESPONSE下载到本地,但是下载的EXCEL文件有时候打开就是把当前网页的样式下载下来,而不是数据 我做这个的时候没有出现说像你这样不稳定的导出情况,但你查看下在导出不好的情况下看是否有Excel进程死在你系统资源当中,这个很容易出现的。 嗯 好的,奇怪的是 调试时候不会出现,但是在客户那边出现概率很大,所以就很疑惑,按照道理,服务端上联OFFICE都没安装,不大可能会存在EXCEL的进程存在啊 GridView控件数据导出到Excel并格式化protected void Button1_Click(object sender, EventArgs e) { Export("application/ms-excel", "商品信息表.xls"); } private void Export(string FileType, string FileName) { Response.Charset = "GB2312"; Response.ContentEncoding = System.Text.Encoding.UTF7; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString()); Response.ContentType = FileType; this.EnableViewState = false; StringWriter tw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(tw); GridView1.RenderControl(hw); Response.Write(tw.ToString()); Response.End(); } private void bind() { SqlDataAdapter myda = new SqlDataAdapter("select top 10 GoodsID as 商品ID,GoodsName as 商品名称,GoodsIntroduce as 商品介绍,GoodsPrice as 商品价格 from tb_GoodsInfo", sqlcon); DataSet myds = new DataSet(); sqlcon.Open(); myda.Fill(myds); sqlcon.Close(); GridView1.DataSource = myds; GridView1.DataBind(); } public override void VerifyRenderingInServerForm(Control control) { } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[3].Attributes.Add("style", "vnd.ms-excel.numberformat:¥#,###.00"); } } 关于三层 求救 关于Cookie和Session共同实现登录功能的问题 在页面中添加自定义控件后的问题 FreeTextBox源代码修改怎么测试 A,提问:如何给asp.net源程序代码加密???20分等大虾。 请问,怎样验证,Session的唯一性?? visual studio 2010 向数据库添加行 求大神 asp.net 问题 winform下出现如下的错误,该如何解决? asp.net excle表批量导入到sql server 2000的同时实现更新功能 求助!招行网上支付接口程序验签DLL无效
但你查看下在导出不好的情况下看是否有Excel进程死在你系统资源当中,这个很容易出现的。
protected void Button1_Click(object sender, EventArgs e)
{
Export("application/ms-excel", "商品信息表.xls");
}
private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(tw);
GridView1.RenderControl(hw);
Response.Write(tw.ToString());
Response.End();
}
private void bind()
{
SqlDataAdapter myda = new SqlDataAdapter("select top 10 GoodsID as 商品ID,GoodsName as 商品名称,GoodsIntroduce as 商品介绍,GoodsPrice as 商品价格 from tb_GoodsInfo", sqlcon);
DataSet myds = new DataSet();
sqlcon.Open();
myda.Fill(myds);
sqlcon.Close();
GridView1.DataSource = myds;
GridView1.DataBind();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[3].Attributes.Add("style", "vnd.ms-excel.numberformat:¥#,###.00");
}
}