.net页面转Word

来源:百度知道 编辑:UC知道 时间:2024/09/19 16:44:38
我想点击一个按钮,把.net页面上的文字之类的东西转成Word存在一个指定位置位置不能选,是指定好的位置。高手谁又现成的代码提供一个,谢谢!

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);