怎么将griview中的数据导入到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();
}
public override void VerifyRenderingInServerForm(Control control)
{
//base.VerifyRenderingInServerForm(control);
}
------解决方案--------------------你这个不是已经实现了吗?
------解决方案-------------------- public class ExcelHelper
{