我有一个asp.net应用程序,我想以编程方式将标题和一些文本插入到word文件中。然后在同一个word文件中插入gridview数据,然后在这里保存代码
protected void btnPrint_Click(object sender, EventArgs e)
{
GridView1.AllowPaging = false;
GridView1.DataBind();
Response.ClearContent();
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Customers.doc"));
Response.Charset = "";
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
GridView1.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
现在,gridview数据正在插入那个单词doc文件,但在gridview之前我想在同一个文件中插入一些文本, 请帮忙......
答案 0 :(得分:3)
添加以下行
2*i+2
前
Response.Write("enter your text here");