大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。
创新互联-专业网站定制、快速模板网站建设、高性价比新城网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式新城网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖新城地区。费用合理售后完善,十载实体公司更值得信赖。
也可以做成vb报表(VB自带有)。
先设置报表格式,打印时向报表传递数据就可以了。
参考:
把执行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
' 设 置Printer 对 象 坐 标 的 度 量 单 位 为 厘 米
Printer.ScaleMode = vbCentimeters
LeftMargin = 1.5
HeadTopPosition = 2
' 定 义 打 印 页 左 上 角 的X 坐 标 和Y 坐 标, 通 过 改 变ScaleLeft 和ScaleTop 的 值, 可 改 变 打 印 页 的 左 边 距 和 上 边 距
Printer.ScaleLeft = -LeftMargin
Printer.ScaleTop = -HeadTopPosition
Printer.Font.Name = "Times New Roman"
Printer.Font.Size = 12
Printer.Print "音像店顾客管理系统"
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
' 创 建 多 页 文 档
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
' 将 输 出 送 到 打 印 机
Printer.EndDoc
End Sub
我帮你把最后一部分的语句顺序调换一下。你试一试
sub button1_click() '---执行打印
Dim pd As PrintDocument = New PrintDocument
pd.PrinterSettings = PrintDialog1.PrinterSettings
If _PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
for i=0 to 1 '这样可以两次截图
CaptureScreen() '--执行前面自定义函数截图
AddHandler pd.PrintPage, AddressOf Document_PrintPage
pd.Print()
Threading.Thread.sleep(100) ‘ 再加上一个间隔
next
end sub
使用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
有截屏键Ctrl + Alt + prtScr/sysRq(prtScr/sysRq在F12旁边),再打开画图、WORD等粘贴就行了
用PrintForm控件,在Visual Basic PowerPacks项目列表中vb2008 SP1以后版本就有了,下面是代码
Imports System.Drawing.Printing
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'先设置打印页面的页边距
With Me.PrintForm1
Dim myMargins As New Margins '页边距设置信息是存放在这个Margins类型的对象中的
With myMargins '分别设置上下左右边距,
.Left = 12
.Right = 12
.Top = 12
.Bottom = 12
End With
.PrinterSettings.DefaultPageSettings.Margins = myMargins '把myMargins对象赋给PrintForm1的设置属性
End With
Me.Button1.Visible = False '这个是在打印的时候隐藏打印按钮
Me.PrintForm1.Form = Me '设置要打印的窗体
Me.PrintForm1.Print() '调用打印窗体方法
Me.Button1.Visible = True '再把隐藏的打印按钮显示出来
End Sub