我正在使用c#开发asp.net Web应用程序开发。我正在尝试将Gridview数据导出到 docx (ms word)。但我做不到( 我只将数据导出为 doc 格式
string FName = "filename.doc";
mygrid.AllowPaging = false;
mygrid.DataSource = datasource();
mygrid.DataBind();
Response.ClearContent();
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", FName));
Response.Charset = "";
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
mygrid.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
如何将gridview中的数据导出为 docx 格式?
答案 0 :(得分:0)
你可以试试这个mime类型
application/vnd.openxmlformats-officedocument.wordprocessingml.document