使用jquery.print插件
創新互聯公司服務項目包括天津網站建設、天津網站制作、天津網頁制作以及天津網絡營銷策劃等。多年來,我們專注于互聯網行業,利用自身積累的技術優勢、行業經驗、深度合作伙伴關系等,向廣大中小型企業、政府機構等提供互聯網行業的解決方案,天津網站推廣取得了明顯的社會效益與經濟效益。目前,我們服務的客戶以成都為中心已經輻射到天津省份的部分城市,未來相信會繼續擴大服務區域并繼續獲得客戶的支持與信任!
我用得jQuery.print, version 1.3.2。
頁面上調用代碼如下:PrintArea就是你panel的ID....
script src="~/Scripts/jQuery.print.js"/script
script
function printarea() {
$("#PrintArea").print({
globalStyles: true,
mediaPrint: false,
stylesheet: null,
noPrintSelector: ".no-print",
iframe: true,
append: null,
prepend: null,
manuallyCopyFormValues: true,
deferred: $.Deferred()
});
}
/script
a class="btn btn-success" onclick="printarea()"打印/a
可以把數據導出到EXCEL,然后使用EXCEL進一步處理后使用。
也可以做成vb報表(VB自帶有)。
先設置報表格式,打印時向報表傳遞數據就可以了。
先拖過來控件PrintDocument1,然后雙擊PrintDocument1,在它的PrintPage事件中加入代碼如下:
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
dim a as String
a="abcd"
Dim mypen As Pen = New Pen(Color.Blue, 2)
e.Graphics.DrawString(a, New Font("宋體", 20), New Pen(Color.Black, 1).Brush, 30, 30)
End Sub
調用下面語句可直接用默認打印機打印出來:
PrintDocument1.Print()
利用 printdocument控件
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(sender As System.Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim stringFont As New Font("Arial", 16)
Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
Dim strFormat As New StringFormat
Dim s As String
s = "print word" '打印的內容
e.Graphics.DrawString(s, stringFont, Brushes.AliceBlue, rectDraw, strFormat)
End Sub