一、后台代码部分:
/// <summary>
/// 导出word
/// </summary>
public void ExpertWord(string filename,string body_text)
{
ReadWriteConfig config = new ReadWriteConfig();
Random rd = new Random();
SaveType st = SaveType.doc;
string addName = filename;
DateTime now = DateTime.Now;
string name = CreateName(st, addName, now);
string fileName = MapPath(st, addName, now) + name;//获取决定路径的文件夹
//创建字符输出流
StreamWriter sw = new StreamWriter(fileName, true, System.Text.UnicodeEncoding.UTF8);
//需要导出的内容
string str = @"<html><head>
<style>
.sch-area{border:1px solid #94bdd9;border-radius:5px}
.mid-split{height:10px;width:100%}
.list-area{zoom:1;border:1px solid #94bdd9;border-radius:5px}
.list-area:after{content:'.';display:block;height:0;clear:both;visibility:hidden}
.list-area .table{border:1px solid #94bdd9;}
.list-area .table .th{color:#4f738d;background-color:#d6eaf6}
.list-area .table .odd{background-color:#e7f0f6}
</style>
<title>心理健康教育信息化大数据平台</title>
</head>
<body>" + body_text.Trim() + "</body></html>
//写入
sw.Write(str);
sw.Close();
Response.Clear();
Response.Buffer = true;
this.EnableViewState = false;
Response.Charset = "utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8));
Response.ContentType = "application/ms-word";
Response.WriteFile(fileName);
Response.Redirect("/export/" + st.ToString() + "/" + now.ToString("yyyyMM") + "/" + name);
Response.Flush();
Response.Close();
Response.End();
}
/// <sum