GridView 导入excel(2007版的格式)
我之前写的是导入2003的excel可以,可是用2007的不能打开,总是报错,而且内容是乱码
下面是我下载excel部分的代码
下面是我下载excel部分的代码
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.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();
}
...全文
相关推荐
C# Excel导入导出
例如,他们可能会在后台代码中读取Excel文件,将其内容填充到GridView或其他控件中,或者从用户填写的数据中创建一个新的Excel文件进行导出。在导入操作中,一般会涉及以下步骤:1.
将Excel 导入到gridview显示并导入到数据库
然而,这种方法需要在运行时安装Excel。另一种无依赖的方式是使用开源库,如NPOI,它可以处理xlsx和xls格式,无需安装Excel。2.
GridView 导出excel ,用2003可以打开,2007不能
综上所述,解决“GridView导出的Excel在2003可以打开,2007不能”的问题,需要调整文件格式、内容编码和MIME类型,或者完全改变导出方法,如使用支持Excel新格式的库。
将EXCEL数据导入Gridview
在.NET开发环境中,将Excel数据导入到GridView控件是一种常见的数据展示需求,特别是在处理大量表格数据时。
Excel表格导入GridView
### Excel表格导入GridView知识点详解#### 一、背景介绍在Web开发中,尤其是在ASP.NET应用中,经常需要处理各种格式的数据文件,如CSV、Excel等。


