你用的版本太高了吧。 我用的7.75 你參考一下 先要打開bartend.exe Shell ("D:\Program Files\Seagull\BarTender\7.75\bartend.exe /af=E:\abc\abc.btw /p /x /?qdh=""" randqdh """") dll應該是不用調用的,調用dll需要用正版

創(chuàng)新互聯(lián)是一家成都網(wǎng)站建設、網(wǎng)站設計,提供網(wǎng)頁設計,網(wǎng)站設計,網(wǎng)站制作,建網(wǎng)站,定制網(wǎng)站設計,網(wǎng)站開發(fā)公司,于2013年創(chuàng)立是互聯(lián)行業(yè)建設者,服務者。以提升客戶品牌價值為核心業(yè)務,全程參與項目的網(wǎng)站策劃設計制作,前端開發(fā),后臺程序制作以及后期項目運營并提出專業(yè)建議和思路。
一般情況下先用EXCEL做好一個樣表文件,設定好打印區(qū)域和樣式,需要填內容的時候,先程序復制一個樣表文件,然后調用API打開表格填寫內容并打印,如果想用API來實現(xiàn)調整模板和打印預覽,可能比較困難,而且很抽象,個人覺得費時費力效果還不一定理想
先拖過來控件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()
1、熱敏打印機(超市打印小票的那種)其實和辦公用的打印機沒有根本區(qū)別,只是用途不同罷了。
2、熱敏打印機與計算機連接的接口基本上有3種(并口、串口和USB口),不管哪種,都要把那個連接線與計算機背后的插槽連好(接口是對應好了的,搞錯了是接不上的),然后安裝正確打印機驅動程序。
3、在大家熟悉使用的WORD文字編輯程序程序中,講頁面寬度自定義調整為熱敏紙的規(guī)格,頁面長度一般210毫米就夠用了。記得要把這個保存為模板,方便以后調用此格式。
4、好了,就用上面的那個模板隨便編輯內容,發(fā)送打印任務到熱敏機就行啦。試試吧,字符再長在WORD里都會自動換行滴。
Sub?outputExcel()?
On?Error?GoTo?merr?
Dim?a?As?Object?
Set?a?=?CreateObject("Excel.Application")?
a.visible?=?True?
Dim?w?As?Object?
Set?w?=?a.Worksheets("sheet1")?
Dim?s()?As?String?
Dim?ns?As?Integer?
ns?=?10?
ReDim?s(ns?-?1)?
Dim?col?As?Integer?
Dim?f?As?Field,?title?As?String?
Dim?tmp1?As?Variant,?tmp2?As?Variant?
Dim?fieldName?As?String?
With?de1.rsselTmpReport?
If?.RecordCount??0?Then?
col?=?0?
de1.rsexcel.MoveFirst?
Do?While?Not?de1.rsexcel.EOF?
If?de1.rsexcel.Fields("isprint").Value?Then?
If?LANG?=?0?Then?
title?=?de1.rsexcel.Fields("title").Value?
Else?
title?=?de1.rsexcel.Fields("title_en").Value?
End?If?
col?=?col?+?1?
w.Cells(Count?+?3,?col).Value?=?title?
w.Cells(Count?+?3,?col).HorizontalAlignment?=?-4108?
w.Cells(Count?+?3,?col).VerticalAlignment?=?-4108?
End?If?
de1.rsexcel.MoveNext?
Loop?
w.range("A1:"?+?IntToLetter(col?-?1)?+?"1").Select?
a.Selection.Merge?
.MoveFirst?
While?Not?.EOF?
col?=?0?
de1.rsexcel.MoveFirst?
Do?While?Not?de1.rsexcel.EOF?
If?de1.rsexcel.Fields("isprint").Value?Then?
title?=?de1.rsexcel.Fields("title").Value?
col?=?col?+?1?
If?de1.rsexcel.Fields("fieldname").Value?=?"crsd"?Then?
'maybe?str?,?val()?
If?Not?IsNull(.Fields("cstd"))?Then?
tmp1?=?myFieldValue(.Fields("cstd"))?
tmp1?=?Val(tmp1)?
tmp2?=?myFieldValue(.Fields("c"))?
tmp2?=?Val(tmp2)?
w.Cells(Count?+?4,?col).Value?=?myDiv(tmp1,?tmp2)?
End?If?
ElseIf?de1.rsexcel.Fields("fieldname").Value?=?"srsd"?Then?
If?Not?IsNull(.Fields("sstd"))?Then?
tmp1?=?myFieldValue(.Fields("sstd"))?
tmp1?=?Val(tmp1)?
tmp2?=?myFieldValue(.Fields("s"))?
tmp2?=?Val(tmp2)?
w.Cells(Count?+?4,?col).Value?=?myDiv(tmp1,?tmp2)?
End?If?
Else?
fieldName?=?de1.rsexcel.Fields("fieldname").Value?
tmp1?=?myFieldValue(.Fields(fieldName))?
w.Cells(Count?+?4,?col).Value?=?tmp1?
End?If?
w.Cells(Count?+?4,?col).HorizontalAlignment?=?-4108?
w.Cells(Count?+?4,?col).VerticalAlignment?=?-4108?
Select?Case?de1.rsexcel.Fields("fieldname").Value?
Case?"c",?"s",?"cstd",?"sstd",?"weight":?
w.Cells(Count?+?4,?col).NumberFormat?=?"0.0000"?
Case?"crsd",?"srsd"?
w.Cells(Count?+?4,?col).NumberFormat?=?"0.0%"?
End?Select?
End?If?
de1.rsexcel.MoveNext?
Loop?
Count?=?Count?+?1?
.MoveNext?
Wend?
End?If?
End?With?
w.range("A3:"?+?IntToLetter(col?-?1)?+?CStr(Count?+?4?-?1)).Select?
a.Selection.Borders(7).LineStyle?=?1?
a.Selection.Borders(7).weight?=?2?
a.Selection.Borders(7).ColorIndex?=?-4105?
a.Selection.Borders(8).LineStyle?=?1?
a.Selection.Borders(8).weight?=?2?
a.Selection.Borders(8).ColorIndex?=?-4105?
a.Selection.Borders(9).LineStyle?=?1?
a.Selection.Borders(9).weight?=?2?
a.Selection.Borders(9).ColorIndex?=?-4105?
a.Selection.Borders(10).LineStyle?=?1?
a.Selection.Borders(10).weight?=?2?
a.Selection.Borders(10).ColorIndex?=?-4105?
a.Selection.Borders(11).LineStyle?=?1?
a.Selection.Borders(11).weight?=?2?
a.Selection.Borders(11).ColorIndex?=?-4105?
a.Selection.Borders(12).LineStyle?=?1?
a.Selection.Borders(12).weight?=?2?
a.Selection.Borders(12).ColorIndex?=?-4105?
w.Cells.Select?
a.Selection.Columns.AutoFit?
Exit?Sub?
merr:?
saveerrmsg?
End?Sub
從我的程序中截取的部分代碼供你參考。
看一下每頁不同內容一共是多少行多少列,比如,你這個是15列,假設每頁打印25個人的工資,那么定義一個數(shù)組 dim lsA(1 to 25,1 to 15) as string,每打一頁,先讀取25個人的信息到這個數(shù)組lsA,再給電子表格區(qū)域"A4:O28"賦值,再打印就可以了。以下代碼是一個給表格賦值的例子。
Dim yEx As Excel.Application
Dim dA(1 To 3, 1 To 3) As String
dA(1, 1) = "a11"
dA(1, 2) = "a12"
dA(1, 3) = "a13"
dA(2, 1) = "a21"
dA(3, 3) = "a33"
Set yEx = New Excel.Application
yEx.Workbooks.Add
MsgBox yEx.Sheets(1).Name
yEx.Sheets("Sheet1").Range("A4:C6") = dA
yEx.Visib
Set yEx = Nothingle = True
yEx.Workbooks.Close
分享題目:調用模板打印vb.net 打印的模板
本文地址:http://chinadenli.net/article22/hpeejc.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站內鏈、營銷型網(wǎng)站建設、網(wǎng)站收錄、、定制網(wǎng)站、響應式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)