2012-03-15 19 views

回答

4

,如果你想使用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(); 
        } 

啤酒花它有助於

+0

我能做到使用C#...... – 2012-03-15 19:20:11

+0

你應該試試這個link..http: //www.dotnetcurry.com/Sho wArticle.aspx?ID = 92或者也看到這個[問題]:http://stackoverflow.com/questions/9561744/asp-net-print-function-to-print-asp-net-controls-with-its-style/9562504#9562504可能會幫助你! – Jigs 2012-03-16 04:50:00

0

我會建議你使用一些報告框架,如SSRS /報表查看器,水晶報表產生這樣的輸出。

例如,您可以創建RDLC文件中有一些排名函數的一組報告定義(保證三排)和使用ReportViewer控件顯示它 - 看看這個網站有關的ReportViewer更多信息:http://gotreportviewer.com/