vb.net直接打印报表 vb打印excel
VB.NET程序如何实现表格填写和打印
一般情况下先用EXCEL做好一个样表文件,设定好打印区域和样式,需要填内容的时候,先程序复制一个样表文件,然后调用API打开表格填写内容并打印,如果想用API来实现调整模板和打印预览,可能比较困难,而且很抽象,个人觉得费时费力效果还不一定理想
东兴网站建设公司成都创新互联,东兴网站设计制作,有大型网站制作公司丰富经验。已为东兴近1000家提供企业网站建设服务。企业网站搭建\成都外贸网站建设要多少钱,请找那个售后服务好的东兴做网站的公司定做!
高分求解vb.net 打印的问题
报表打印应该也能实现,但是我觉得你这个用文本打印更简单,将数据输出到txt文件,结果用RichTextBox显示,但是需要简单的排版,调用打印机打印RichTextBox即可的
排版用tab()、space()、vbcrlf或PrintLine(1)换行,代码类似如下样式
PrintLine(1, TAB(60), "准考证" )
PrintLine(1)
PrintLine(1, "姓名:" xingming Space(3) "准考证号:" cel(1) Space(3) cel(2) Space(3) cel(3))
但是TAB()排版比较规整
打印代码类似如下:
PrintDialog1.Document = PrintDocument1
PrintDocument1.DocumentName = "准考证"
PrintDialog1.AllowSomePages = False
PrintDialog1.ShowHelp = False
PrintDialog1.ShowNetwork = False
PrintDialog1.AllowSelection = False
PrintDialog1.AllowPrintToFile = False
MySReader = New StringReader(RichTextBox1.Text)
stringToPrint = MySReader.ReadToEnd()
PageSetupDialog1.Document = PrintDocument1
PageSetupDialog1.PageSettings.Margins.Bottom = 50
PageSetupDialog1.PageSettings.Margins.Top = 50
PageSetupDialog1.PageSettings.Margins.Left = 50
PageSetupDialog1.PageSettings.Margins.Right = 50
If PageSetupDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
PrintDocument1.DefaultPageSettings = PageSetupDialog1.PageSettings '页面设置
If PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
If PrintDialog1.PrinterSettings.IsValid = True Then
PrintDocument1.Print()
MsgBox("打印完成!" vbCrLf "Print completed!", , "Print hint(打印提示)")
Else
MsgBox("打印失败!打印机不可用。" vbCrLf "Print failed! The printer is not valid.", , "Print hint(打印提示)")
End If
Else
Exit Sub
End If
End If
vb.net 打印功能
可以把数据导出到EXCEL,然后使用EXCEL进一步处理后使用。
也可以做成vb报表(VB自带有)。
先设置报表格式,打印时向报表传递数据就可以了。
如何用VB实现表格打印功能?
VB下数据报表打印输出方法有多种,一是通过自己的设计和编程完成报表打印输出。二是通过MS OFFICE实现报表打印输出。三是应用数据报表设计器的报表打印输出。本人经常使用第一种方法,它具有根据需要灵活应用的特点,但需编写程序。下附代码,第一段代码定义基本变量,第二段代码定义打印函数,第三段代码是具体打印代码,含数据转换。第四段代码是窗体加载代码,具体连接数据库和打印代码根据你所涉及的数据要求进行修改。
Option Explicit
Private n As Integer
Private m As Integer
Private zh_dm(10) As Double
Private dy_dm(3000, 10) As Variant
Private zsl As Integer
Private y As Integer
Private x As Integer
Private i As Integer
Private k As Integer
Private p As Integer
Private pa As Integer
Private j As Integer
Private txt As String
Private fnt As Integer
Private dd As Variant
Public Function prnt(x As Variant, y As Variant, fnt As Variant, txt0 As Variant)
Printer.CurrentX = x
Printer.CurrentY = y
Printer.FontSize = fnt
Printer.Print txt0
End Function
Private Sub cmdPrint_Click()
Adodc1.Recordset.MoveFirst
For i = 0 To zsl - 1
For j = 0 To 7
dy_dm(i, j) = Adodc1.Recordset(j)
Next j
Adodc1.Recordset.MoveNext
Next i
'确定页数
k = Int(zsl / 80)'80为每页行数
If k - zsl / 80 0 Then
k = k + 1
End If
fnt = 8
For p = 0 To k - 1
pa = p + 1
y = 300
x = 4500
txt = "机物料库存"
dd = prnt(x, y, fnt, txt)
x = 8500
txt = "第" p + 1 "页"
dd = prnt(x, y, fnt, txt)
y = 500
x = 600
txt = "备件代码"
dd = prnt(x, y, fnt, txt)
x = 1500
txt = "备件名称"
dd = prnt(x, y, fnt, txt)
x = 3500
txt = "备件规格"
dd = prnt(x, y, fnt, txt)
x = 5500
txt = "进口计算机号"
dd = prnt(x, y, fnt, txt)
x = 7500
txt = "最低储备量"
dd = prnt(x, y, fnt, txt)
x = 9000
txt = "库存量"
dd = prnt(x, y, fnt, txt)
For i = 0 + p * 80 To 79 + p * 80
y = 700 + 180 * (i - p * 80)
x = 600
txt = dy_dm(i, 1)
dd = prnt(x, y, fnt, txt)
x = 1500
txt = dy_dm(i, 2)
dd = prnt(x, y, fnt, txt)
x = 3500
txt = dy_dm(i, 3)
dd = prnt(x, y, fnt, txt)
x = 5500
txt = dy_dm(i, 4)
dd = prnt(x, y, fnt, txt)
x = 7500
txt = dy_dm(i, 5)
dd = prnt(x, y, fnt, txt)
x = 9000
txt = dy_dm(i, 6)
dd = prnt(x, y, fnt, txt)
If Int(i / 10) - i / 10 = 0 Then
Printer.Line (500, 695 + (i - p * 80) * 180)-(10000, 695 + (i - p * 80) * 180)
End If
Next i
If zsl - p * 80 80 Then
Printer.Line (500, 695 + 180 * 80)-(10000, 695 + 180 * 80)
Printer.NewPage
End If
Next p
Printer.EndDoc ' 打印完成。
Cls
End Sub
Private Sub Form_Load()
Adodc1.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=jwl_dbf"
Adodc1.RecordSource = "select cs.js_dm,cs.备件代码,cs.备件名称,cs.备件规格,cs.进口计算机号,cs.最低库存量,sl.结存数量,sl.结存金额,sl.结存单价,sl.类别代码 from JWCK_BM as cs,jwl_jiec as sl" _
" where cs.备件代码 = sl.备件代码" " and cs.备件代码" "''" " order by sl.类别代码,sl.备件代码"
Adodc1.Refresh
DataGrid1.Refresh
zsl = Adodc1.Recordset.RecordCount
Adodc3.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=jwl_dbf"
Adodc3.RecordSource = "select sum(结存金额) as hj from jwl_jiec"
Adodc3.Refresh
End Sub
以上供参考。其它请参考西安交通大学出版社出版的“VISUAL BASIC 6.0 高级编程技巧-ADO数据访问篇“
如何用VB.NET导入和导出EXCEL表,打印预览???
NET中数据库数据导入Excel并打印摘要:众所周知,WEB上的打印是比较困难的,常见的WEB上打印的方法大概 ... type=button value=打印预览onclick=document.all.WebBrowser.ExecWB(7,1) ... 3、将数据库的数据或要打印的内容导出到Excel,Word中去打印
我的vb.net中没有CrystalReport控件怎么打印报表啊?
不会吧,在vb.net工程中,选择新项目的追加,在实用程序的选项中,可看到有CrystalReport的选项。
它和VB不同,VB用的是控件。
你最好,上网或去书店看一看有关vb.net的报表设计。
网页题目:vb.net直接打印报表 vb打印excel
网页链接:http://scjbc.cn/article/doojgpc.html