.net页面转Word
来源:百度知道 编辑:UC知道 时间:2024/09/19 16:44:38
asp.net导入word
private void DataOut(int num)//导出数据的函数0为word,1为Excel
{
Response.Clear();
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
string fName = DateTime.Now.ToString("yyyy-MM-dd-ss");
if (num == 0)
{
fName = HttpUtility.UrlEncode(fName, System.Text.Encoding.GetEncoding("gb2312")) + ".doc";
Response.ContentType = "application/ms-word";
}
else
{
fName = HttpUtility.UrlEncode(fName, System.Text.Encoding.GetEncoding("gb2312")) + ".xls";
Response.ContentType = "application nd.xls";
}
Response.AddHeader("content-disposition", "attachment;filename=" + fName);
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);