导出的页面是乱码.. 而右键点记事本打开 又完全是好的 这的怎么回事那?
DataSet ds = TestBL.CreatePaperBySelectPaper(SiteInfo.WebSiteID.ToString(), this.Master.UserID.ToString(), hidExportPaperID.Value);
DataTable dtPaperPartInfo = ds.Tables[1];
DataTable dtQuestionTitle = ds.Tables[2];
DataTable dtChoiceItems = ds.Tables[3];
if (dtQuestionTitle.Rows.Count > 0)
{
StringBuilder strN = new StringBuilder();
strN.Append("<html>");
strN.Append("<head style=\"font-size:10px;\">");
strN.Append("</head>");
strN.Append("<body style=\"text-align:left;\">");
int paperScore = 0;
strN.Append("<div style=\"line-height: 30px; border: solid 1px #f16911;position: absolute; display: none; top: 10px;padding-left:10px; overflow: hidden; width: 968px;background: #CCC4A9;\">");
strN.Append("<div class=\"AligntoLeft Width500\">");
strN.AppendFormat("<label class=\"Bold TextColorDark\">{0}</label>", ds.Tables[0].Rows[0]["fPaperName"]);
strN.Append("<span>");
strN.AppendFormat("<label>(" + Master.getXmlResourceName("ceshicengci") + ":{0}</label>", ds.Tables[0].Rows[0]["fExerciseLevelName"]); StringBuilder sbContent = new StringBuilder();
bool isWithReference = hidExportType.Value == "1" ? true : false;
foreach (DataRow dr in dtPaperPartInfo.Rows)
{
int partScore = 0;
string childHTML = GetAllPaperChildHTML(dr["fPolicyGroupID"].ToString(), ref dtQuestionTitle, ref dtChoiceItems, "0", ref partScore, isWithReference);
sbContent.Append("<div class=\"HideOverflow GridContainer MT10\">");
sbContent.AppendFormat("<div class=\"MainTitle\" style=\"text-indent:10px;\">{0}{1}</div>", dr["fTitle"], partScore == 0 ? string.Empty : string.Format("<label class=\"TextColorGray ML5\"> </label>", partScore >= 0 ? string.Format("({0}分)", partScore) : string.Empty));
sbContent.Append(childHTML);
sbContent.Append("</div>");
paperScore += partScore;
}
strN.AppendFormat("<label>" + Master.getXmlResourceName("zongfen_ceshishichang_fenzhong") + "</label>)</span></div></div>", paperScore, ds.Tables[0].Rows[0]["fTimeLimit"]);
strN.Append(sbContent);
strN.Append("</body></html>"); Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(string.Format("{0}{1}", ds.Tables[0].Rows[0]["fPaperName"], isWithReference ? Master.getXmlResourceName("daidaan") : string.Empty)) + ".doc");
Response.ContentEncoding = Encoding.UTF8;
Response.ContentType = "application/ms-word";
System.IO.StringWriter ostring = new System.IO.StringWriter(strN);
//System.Web.UI.HtmlTextWriter othtml = new HtmlTextWriter(ostring);
Response.Write(ostring.ToString());
Response.End();
}
DataSet ds = TestBL.CreatePaperBySelectPaper(SiteInfo.WebSiteID.ToString(), this.Master.UserID.ToString(), hidExportPaperID.Value);
DataTable dtPaperPartInfo = ds.Tables[1];
DataTable dtQuestionTitle = ds.Tables[2];
DataTable dtChoiceItems = ds.Tables[3];
if (dtQuestionTitle.Rows.Count > 0)
{
StringBuilder strN = new StringBuilder();
strN.Append("<html>");
strN.Append("<head style=\"font-size:10px;\">");
strN.Append("</head>");
strN.Append("<body style=\"text-align:left;\">");
int paperScore = 0;
strN.Append("<div style=\"line-height: 30px; border: solid 1px #f16911;position: absolute; display: none; top: 10px;padding-left:10px; overflow: hidden; width: 968px;background: #CCC4A9;\">");
strN.Append("<div class=\"AligntoLeft Width500\">");
strN.AppendFormat("<label class=\"Bold TextColorDark\">{0}</label>", ds.Tables[0].Rows[0]["fPaperName"]);
strN.Append("<span>");
strN.AppendFormat("<label>(" + Master.getXmlResourceName("ceshicengci") + ":{0}</label>", ds.Tables[0].Rows[0]["fExerciseLevelName"]); StringBuilder sbContent = new StringBuilder();
bool isWithReference = hidExportType.Value == "1" ? true : false;
foreach (DataRow dr in dtPaperPartInfo.Rows)
{
int partScore = 0;
string childHTML = GetAllPaperChildHTML(dr["fPolicyGroupID"].ToString(), ref dtQuestionTitle, ref dtChoiceItems, "0", ref partScore, isWithReference);
sbContent.Append("<div class=\"HideOverflow GridContainer MT10\">");
sbContent.AppendFormat("<div class=\"MainTitle\" style=\"text-indent:10px;\">{0}{1}</div>", dr["fTitle"], partScore == 0 ? string.Empty : string.Format("<label class=\"TextColorGray ML5\"> </label>", partScore >= 0 ? string.Format("({0}分)", partScore) : string.Empty));
sbContent.Append(childHTML);
sbContent.Append("</div>");
paperScore += partScore;
}
strN.AppendFormat("<label>" + Master.getXmlResourceName("zongfen_ceshishichang_fenzhong") + "</label>)</span></div></div>", paperScore, ds.Tables[0].Rows[0]["fTimeLimit"]);
strN.Append(sbContent);
strN.Append("</body></html>"); Response.Clear();
Response.Buffer = true;
Response.Charset = "GB2312";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(string.Format("{0}{1}", ds.Tables[0].Rows[0]["fPaperName"], isWithReference ? Master.getXmlResourceName("daidaan") : string.Empty)) + ".doc");
Response.ContentEncoding = Encoding.UTF8;
Response.ContentType = "application/ms-word";
System.IO.StringWriter ostring = new System.IO.StringWriter(strN);
//System.Web.UI.HtmlTextWriter othtml = new HtmlTextWriter(ostring);
Response.Write(ostring.ToString());
Response.End();
}
解决方案 »
- radio与数据库绑定的问题
- 一个简单的 网站页面运行问题 在线等 请各位指点 非常感激!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- GridView导出EXCEL后,GV里面的内容和EXCEL不一致
- 请教高手,spp里webpart调用webservice的问题
- 请问 现在页面与页面之间通过什么技术传递信息呢?
- 什么叫分层,层的概念如何定义?
- 这个问题很弱智吗?
- 如何在客户端验证所有的必填项都填写了(必填项有一部分是根据用户输入的数据动态生成的).(版主帮忙啊,急)
- 在TreeView中怎么才能让某个TreeNode不显示出来呢?(隐藏)
- 奇葩问题
- Net sql 倒叙 分页
- js如何获取一个值之后判断是否执行该js方法
这个别设置成GB2312,改成UTF-8
Response.Charset = "UTF-8";