Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
Hi.

I have this code and I use it to render GridView to MS Word and download it automatically for the user. However, I am having a hard time searching how to add page numbers on each page of the downloaded document.

Here is my code:

C#
public void BindAndRender(System.Data.DataTable dtInput)
{
    string title = "OthersAbroad_BankReport";
    Response.Clear();
    Response.Buffer = true;
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);

    gvExportDoc.AllowPaging = false;
    gvExportDoc.DataSource = dtInput;
    gvExportDoc.DataBind();
    Response.ContentType = "application/vnd.ms-doc";
    Response.AddHeader("content-disposition", "attachment;filename=" + title + ".doc");
    Response.Charset = "";
    gvExportDoc.RenderControl(hw);

    string style = @"<style> .textmode { mso-number-format:\@; } </style>";
    Response.Write(style);
    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();
}


Please help me. THank yoU!
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900