c# 将gridview保存为excel 2007

时间都去哪了啊 时间都去哪了啊 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
本人自己写的保存为2003版本的格式的,可是用2007的打开总是有乱码,而且弹出格式不对的对话框,如何保存为2007版本的呀?
我的代码如下:
 protected void Button1_Click(object sender, EventArgs e)
{
string XX = Label1.Text + Label3.Text;
Export("application/ms-excel", XX + "月份采购计划.xls");
}


public override void VerifyRenderingInServerForm(Control control)
{

}

private void Export(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
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();
}
...全文
评论 4
收藏 已收藏
分享
返回顶部
时间都去哪了啊
C# 111,129 成员 642,538 内容