我将数据表导出到 word,当我传递文件名时,它似乎没有在打开/保存对话框中获取文件名。
这是我正在做的
public static void Convertword(DataTable dt, HttpResponse Response,string filename)
{
try
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + filename + ".doc");
Response.Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
System.Web.UI.WebControls.GridView dg = new System.Web.UI.WebControls.GridView();
dg.DataSource = dt;
dg.DataBind();
dg.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
catch(Exception err)
{
throw err;
}
}
当我传递文件名"report(" + System.DateTime.Now.ToString("dd/MM/yyyy");
+ ")"
时,它不会将值作为dd/MM/YYYY而是将文件名显示为dd_MM_YYYY