【问题标题】:how to print the gridview of page in require format如何以要求格式打印页面的gridview
【发布时间】:2023-03-25 17:27:01
【问题描述】:

我有一个来自数据库的 gridview,问题是当用户单击打印按钮时,我想打印整个页面,gridview 的每一行以给定格式打印为 1 A4 尺寸页面上的 3 行。

网格视图

打印格式

【问题讨论】:

    标签: asp.net gridview printing printing-web-page


    【解决方案1】:

    如果你想使用javascript,那么你可以试试这个

    function printItn() {
                      //In my case i have append gridview in Panel that y..you can put your contentID which is you want to print.
    
                        var printContent = document.getElementById('<%= pnlForm.ClientID %>');
                        var windowUrl = 'about:blank';
                        var uniqueName = new Date();
                        var windowName = 'Print' + uniqueName.getTime();
    
            //  you should add all css refrence for your Gridview. something like.
    
                        var WinPrint= window.open(windowUrl,windowName,'left=300,top=300,right=500,bottom=500,width=1000,height=500');WinPrint.document.write('<'+'html'+'><head><link href="cssreference" rel="stylesheet" type="text/css" /><link href="gridviewcssrefrence" rel="stylesheet" type="text/css" /></head><'+'body style="background:none !important"'+'>');
                        WinPrint.document.write(printContent.innerHTML);
                        WinPrint.document.write('<'+'/body'+'><'+'/html'+'>');
                        WinPrint.document.close();
                        WinPrint.focus();
                        WinPrint.print();
                        WinPrint.close();
                        }
    

    希望有帮助

    【讨论】:

    【解决方案2】:

    我建议您使用一些报告框架,例如 SSRS/Report-Viewer、Crystal Reports 来生成此类输出。

    例如,您可以在 RDLC 文件中创建报表定义,并在某些排名函数上设置一个组(以确保三行)并使用 ReportViewer 控件显示它 - 请查看此站点以获取有关 reportviewer 的更多信息:http://gotreportviewer.com/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      相关资源
      最近更新 更多