asp.net中将网页中的内容导到Excel时打开时在Excel中出现这个错误:无法找到“C:\Documents and Settings\wang\Local Settings\Temporary Internet Files\Content.IE5\S5UJWLYB\%5%7%9%9%91%ab%e%80%81%5%b8%88%e%7%ac2006%e%ad%af%a6%e5%b9%b4%e6%95%8f2007-4-25[2].xls”。请检查文件名的拼写,并检查文件位置是否正确。
而先保存再打开就不会出错。
哪位高手知道啊?指点一下。
而先保存再打开就不会出错。
哪位高手知道啊?指点一下。
{
// GridView1.Attributes.Add("style", "word-break:keep-all;word-wrap:normal");
//下面这行是自动换行
//GridView1.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
if (!IsPostBack)
{
SqlConnection sqlcon = new SqlConnection("Data Source=(local);Database=db_04;Uid=sa;Pwd=");
SqlDataAdapter myda = new SqlDataAdapter("select * from tb_Card", sqlcon);
DataSet myds = new DataSet();
myda.Fill(myds);
GridView1.DataSource = myds;
GridView1.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Ex("application/ms-excel","学生成绩报表.xls");
}
private void Ex(string FileType, string FileName)
{
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF7;
Response.AddHeader("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)
{
}试试我这个呀