Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a rather difficult requirement from our clients for a Gridview.
Clients would like to preset the Excel file saved from an export out of the GridView content, to Legal size automatically.

Has anyone tackled the above requirement? Is there a way to specify the Legal page size?
The code below is what I have currently for exporting the GridView to an Excel file.


C#
private void ExportToExcel(string p, GridView GridView1)
{
	Response.ClearContent();
	Response.AddHeader("content-disposition", "attachment; filename=" + p);
	Response.ContentType = "application/vnd.xls";
         GridView1.PagerSettings.Visible = false;
         GridView1.DataBind();
         System.IO.StringWriter sw = new System.IO.StringWriter();
	HtmlTextWriter htw = new HtmlTextWriter(sw);
	GridView1.RenderControl(htw);
	Response.Write(sw.ToString());
	Response.End();
         GridView1.PagerSettings.Visible = true;
         GridView1.DataBind();
}
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