Click here to Skip to main content
Sign Up to vote bad
good
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. Smile | :)
Posted 11 Mar '12 - 19:21


4 solutions

  Permalink  
Export HTML table to Excel with grid lines[^] and the discussion here[^] might help you out.
  Permalink  
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();
}
  Permalink  
  Permalink  
Comments
Ariel Riyo - 12 Mar '12 - 1:36
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)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 414
1 Arun Vasu 253
2 OriginalGriff 190
3 CPallini 163
4 Aarti Meswania 158
0 Sergey Alexandrovich Kryukov 10,169
1 OriginalGriff 7,749
2 CPallini 4,181
3 Rohan Leuva 3,482
4 Maciej Los 3,089


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 12 Mar 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid