可以把數(shù)據(jù)導(dǎo)出到EXCEL,然后使用EXCEL進(jìn)一步處理后使用。
創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價(jià)比新城網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式新城網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務(wù)覆蓋新城地區(qū)。費(fèi)用合理售后完善,十載實(shí)體公司更值得信賴。
也可以做成vb報(bào)表(VB自帶有)。
先設(shè)置報(bào)表格式,打印時(shí)向報(bào)表傳遞數(shù)據(jù)就可以了。
參考:
把執(zhí)行SQL語句后得到的記錄集逐條(含字段名)顯示在LISTVIEW控件中
'----------------------------------------------------------------
Public Sub ListUpdate(ByRef rs As Recordset, ByRef lv As ListView)
Dim head As ColumnHeader, Item As ListItem
Dim i As Integer, j As Integer
Dim lvWidth As Integer
lvWidth = lv.Width
'初始化LISTVIEW的某些屬性
lv.View = lvwReport
lv.GridLines = True
lv.FullRowSelect = True
lv.ListItems.Clear
lv.ColumnHeaders.Clear
For i = 0 To rs.Fields.Count - 1
Set head = lv.ColumnHeaders.Add
head.Text = rs.Fields(i).Name
head.Width = lvWidth / rs.Fields.Count
Next
For j = 1 To PERPAGE
If rs.EOF Then Exit For
Set Item = lv.ListItems.Add
Item.Text = "" rs.Fields(0).Value
For i = 1 To rs.Fields.Count - 1
Item.SubItems(i) = "" rs.Fields(i).Value
Next
rs.MoveNext
Next
End Sub
' 打印
Public Sub PrintRecordset(ByRef recRecordset As Recordset, ByVal strType As String)
Dim LeftMargin As Integer
Dim HeadTopPosition As Integer
Dim FieldNum As Integer
Dim PageCounter As Integer
Dim MyRecordset As ADODB.Recordset
Const FooterTopPosition = 24
Set MyRecordset = recRecordset
PageCounter = 1
' 設(shè) 置Printer 對(duì) 象 坐 標(biāo) 的 度 量 單 位 為 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 義 打 印 頁 左 上 角 的X 坐 標(biāo) 和Y 坐 標(biāo), 通 過 改 變ScaleLeft 和ScaleTop 的 值, 可 改 變 打 印 頁 的 左 邊 距 和 上 邊 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顧客管理系統(tǒng)"
Printer.Print strType
Printer.Print ""
If MyRecordset.EOF And MyRecordset.BOF Then
MsgBox "No Record At Presend!", vbCritical And vbOKOnly, "Print Error"
Exit Sub
End If
MyRecordset.MoveFirst
Do Until Printer.CurrentY FooterTopPosition
'Print the fields of the recordset in sequence
For FieldNum = 0 To MyRecordset.Fields.Count - 1
Printer.Print MyRecordset.Fields(FieldNum).Name _
": " _
MyRecordset.Fields(FieldNum).Value
If Printer.CurrentY FooterTopPosition Then
Printer.CurrentX = 8
Printer.Print "Page: " PageCounter
' 創(chuàng) 建 多 頁 文 檔
Printer.NewPage
PageCounter = PageCounter + 1
End If
Next FieldNum
MyRecordset.MoveNext
If MyRecordset.EOF Then Exit Do
' 在 記 錄 之 間 空 一 行
Printer.Print ""
Loop
'Print the Page number as a footer
Printer.CurrentX = 8
Printer.CurrentY = FooterTopPosition
Printer.Print "Page: " PageCounter
' 將 輸 出 送 到 打 印 機(jī)
Printer.EndDoc
End Sub
我?guī)湍惆炎詈笠徊糠值恼Z句順序調(diào)換一下。你試一試
sub button1_click() '---執(zhí)行打印
Dim pd As PrintDocument = New PrintDocument
pd.PrinterSettings = PrintDialog1.PrinterSettings
If _PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
for i=0 to 1 '這樣可以兩次截圖
CaptureScreen() '--執(zhí)行前面自定義函數(shù)截圖
AddHandler pd.PrintPage, AddressOf Document_PrintPage
pd.Print()
Threading.Thread.sleep(100) ‘ 再加上一個(gè)間隔
next
end sub
使用jquery.print插件
我用得jQuery.print, version 1.3.2。
頁面上調(diào)用代碼如下: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
有截屏鍵Ctrl + Alt + prtScr/sysRq(prtScr/sysRq在F12旁邊),再打開畫圖、WORD等粘貼就行了
用PrintForm控件,在Visual Basic PowerPacks項(xiàng)目列表中vb2008 SP1以后版本就有了,下面是代碼
Imports System.Drawing.Printing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'先設(shè)置打印頁面的頁邊距
With Me.PrintForm1
Dim myMargins As New Margins '頁邊距設(shè)置信息是存放在這個(gè)Margins類型的對(duì)象中的
With myMargins '分別設(shè)置上下左右邊距,
.Left = 12
.Right = 12
.Top = 12
.Bottom = 12
End With
.PrinterSettings.DefaultPageSettings.Margins = myMargins '把myMargins對(duì)象賦給PrintForm1的設(shè)置屬性
End With
Me.Button1.Visible = False '這個(gè)是在打印的時(shí)候隱藏打印按鈕
Me.PrintForm1.Form = Me '設(shè)置要打印的窗體
Me.PrintForm1.Print() '調(diào)用打印窗體方法
Me.Button1.Visible = True '再把隱藏的打印按鈕顯示出來
End Sub