MDB格式的文件怎么样像WORD效果那样打印出来?

MDB格式的文件怎么样像WORD效果那样打印出来?,第1张

mdb是access的数据库文件,怎么转成word啊.倒塌

可以用c++或者delphi遍历数据库,然后以text的方式输出文件,再复制到word里面楼

不过对于数据库里面的ole就没有办法了

你需通过VB的打包程序,生成一个安装包,将此安装程序将你的应用程序安装于WIN2000机器,它同时会将所涉及的*.OCX文件安装于系统.你的第一个问题是WIN2000系统缺少MSDATGRD.OCX文件或未注册.

第二问题楼上已作回答.

第三问题数据打印输出:

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.1Persist Security Info=FalseData 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.1Persist Security Info=FalseData Source=jwl_dbf"

Adodc3.RecordSource = "select sum(结存金额) as hj from jwl_jiec"

Adodc3.Refresh

End Sub


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9915051.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-03
下一篇 2023-05-03

发表评论

登录后才能评论

评论列表(0条)

保存