データテーブルを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と表示されます。