Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello guy! good DAY!

Im having a problem in the Page setup when i export my table in excel. I need to automatically assign the paper layout to landscape when i click my export button.

I have no problem in exprting my html table to excel i need just to assign may paper to a landscape form when i hit the export. does anyone know the code how to do it? thanks guys!

Thank youvery much in advnace. im looking forward to you answers. thank you, God bless and have a great day forward. :)
Posted

 
Share this answer
 
Export HTML table to Excel with grid lines[^] and the discussion here[^] might help you out.
 
Share this answer
 
send your HTML table id to the parameter 'ctl'


public void exportGridToExcel(Control ctl)
{
string attachment = "attachment; filename=etrack_excel_export.xls";
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition", attachment);
HttpContext.Current.Response.ContentType = "application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw = new HtmlTextWriter(stw);

ctl.RenderControl(htextw);
HttpContext.Current.Response.Write(stw.ToString());
HttpContext.Current.Response.End();
}
 
Share this answer
 
 
Share this answer
 
Comments
Ariel Riyo 12-Mar-12 1:36am    
hey thanks for your response. but im not having a problem anymore in exporting my html table to excel i just want to know the codes or resource on how to automtically assign the page layout of excel to landscape whenever i click my export button. thankyou. :)

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