如何在多个页面上打印表格asp.net c# [英] How do I print a table on multiple pages asp.net c#

查看:85
本文介绍了如何在多个页面上打印表格asp.net c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我的代码工作从我的asp.net c#web应用程序打印一个表后,我注意到表非常大,它有很多列和行,现在当我打印时,它会挤压整个表在一个页面上,无论如何都要将表格拆分为多页打印?



我对如何实现这一点感到无能为力? />
这是我正在使用的代码

After getting my code to work to print a table from my asp.net c# web application, I noticed that the table is really big, it has alot of columns and rows and right now when I print, it squashes the whole table onto one page, is there anyway to split the table up to print on multiple pages as needed?

I am just so clueless as to how to achieve this?
This is the code I am using

function Print() {

        var prntData = document.getElementById('Table1');
        var mywindow = window.open('', 'printer', 'height=800,width=700,left=0,top=0,toolbar=0,scrollbar=0,status=0');
        mywindow.document.write('<html><head><title></title>');
        mywindow.document.write('</head><body style="direction:ltr;"><pre>');
        mywindow.document.write(prntData.outerHTML);
        mywindow.document.write('<link href="Reports/Print.css" rel="stylesheet" />');
        mywindow.document.write('</body></html>');
        mywindow.document.close();
        mywindow.print();
    }

推荐答案

好的,所以你使用的是javascript,这很棒。我能想到控制分页的最好方法是实际弹出并一次打印一页。
OK, so you're using javascript, that's great. The best way I can think to control paging, is to actually pop up and print one page at a time.


试试

http://dotnetcluster.blogspot.in/2011/07/paging-in-html-table-using -javascript.html [ ^ ]

https:// code .google.com / p / one-simple-table-paging / [ ^ ]


恕我直言,您应该使用一些报告工具,例如MS提供的名为Local Reports的ASP.NET免费选项(RDLC报告文件)通过 ReportViewer 控件显示在aspx页面上。您可以使用此类表创建报表,然后通过代码将其绑定到数据源,并让ReportViewer将其格式化以用于打印目的。如果您使用报告工具,则可以更好地控制打印过程。
IMHO, you should go for some reporting tool like the free option for ASP.NET that is shipped by MS called Local Reports (RDLC report files) that are displayed on an aspx page through the ReportViewer control. You could create a report with such table, then bind it through code to the data source, and let the ReportViewer to format it for printing purposes. You'll have more control on the printing process if you use a reporting tool.


这篇关于如何在多个页面上打印表格asp.net c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆