将HTML表从ASP导出到Excel
问题描述:
你好!美好的一天!
我在Excel中导出表格时页面设置出现问题.单击导出按钮时,我需要自动将纸张布局分配给横向.
我在将html表扩展为excel时没有问题,当我点击导出时,我只需要将可能的纸张分配给横向表格即可.有谁知道代码该怎么做?谢谢大家!
非常感谢您的参与.我期待着您的答案.谢谢你,上帝保佑,祝你有美好的一天. :)
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. :)
答
确定 我发现有类似以下内容的内容:
http://jwcooney.com/2011 /09/08/generating-excel-documents-through-html-xml-and-css-part-2/ [
OK I have fount something like this check this:
http://jwcooney.com/2011/09/08/generating-excel-documents-through-html-xml-and-css-part-2/[^]
使用网格线将HTML表导出到Excel [ ^ ]和讨论此处 [ ^ ]可能会为您提供帮助
Export HTML table to Excel with grid lines[^] and the discussion here[^] might help you out.
发送HTML表ID到参数"ctl"
公共无效exportGridToExcel(Control ctl)
{
字符串附件=附件;文件名= etrack_excel_export.xls";
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.AddHeader("content-disposition",附件);
HttpContext.Current.Response.ContentType ="application/ms-excel";
StringWriter stw = new StringWriter();
HtmlTextWriter htextw =新的HtmlTextWriter(stw);
ctl.RenderControl(htextw);
HttpContext.Current.Response.Write(stw.ToString());
HttpContext.Current.Response.End();
}
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();
}