今天上面要将考试的试卷可以导入出word,我当时想直接输出成文件,于是就写了
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/msword";
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition ", "online;filename=File1.doc ");
Response.ContentEncoding = System.Text.Encoding.Default;
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new HtmlTextWriter(oStringWriter);
this.div.RenderControl(oHtmlTextWriter);
Response.Write(oStringWriter.ToString());
Response.End();
问题出来了,我输出div的内容到word,可是导出的却是html代码,这点我一直都没想明白为什么?
因为我将div换成table一点问题都没有,哎,算了,也就先用吧
记录一下,如果知道为什么div会导出 html的兄弟告知兄弟一下