回 帖 发 新 帖 刷新版面

主题:相当困惑了

我用pb做了个crosstab类型的数据窗口,又做了个导出按纽,但是导出的execl表格不规则.谁会写类似的语句.高抬贵手~

回复列表 (共6个回复)

沙发


OLEObject newoleobject,newoleworkbooks
newoleobject=create OLEObject
if newoleobject.connecttonewobject("excel.application")<>0 then
    messagebox("提示","OLE连接失败")
    return
end if
newoleobject.workbooks.add
newoleobject.visible=true
newoleworkbooks=newoleobject.worksheets(1)
newoleworkbooks.cells(1,1).value="编号"
newoleworkbooks.cells(1,2).value="名称"
newoleworkbooks.cells(1,3).value="内容简介"
newoleworkbooks.cells(1,4).value="制作时间"
newoleworkbooks.cells(1,5).value="持续时间"
newoleworkbooks.cells(1,6).value="入点"
newoleworkbooks.cells(1,7).value="出点"
newoleworkbooks.cells(1,8).value="素材作品"
newoleworkbooks.cells(1,9).value="存储格式"
newoleworkbooks.cells(1,10).value="存储介质"
newoleworkbooks.cells(1,11).value="存储时间"
newoleworkbooks.cells(1,12).value="存储大小"
newoleworkbooks.cells(1,13).value="存储编号"
newoleworkbooks.cells(1,14).value="分类"
newoleworkbooks.cells(1,15).value="部门"
newoleworkbooks.cells(1,16).value="备注"
long rownumber
for rownumber=2 to dw_1.rowcount()+1
    newoleworkbooks.cells(rownumber,1).value=dw_1.getitemnumber(rownumber -1,1)
    newoleworkbooks.cells(rownumber,2).value=dw_1.getitemstring(rownumber -1,2)
    newoleworkbooks.cells(rownumber,3).value=dw_1.getitemstring(rownumber -1,3)
    newoleworkbooks.cells(rownumber,4).value=dw_1.getitemstring(rownumber -1,4)
    newoleworkbooks.cells(rownumber,5).value=dw_1.getitemstring(rownumber -1,5)
    newoleworkbooks.cells(rownumber,6).value=dw_1.getitemstring(rownumber -1,6)
    newoleworkbooks.cells(rownumber,7).value=dw_1.getitemstring(rownumber -1,7)
    newoleworkbooks.cells(rownumber,8).value=dw_1.getitemstring(rownumber -1,8)
    newoleworkbooks.cells(rownumber,9).value=dw_1.getitemstring(rownumber -1,9)
    newoleworkbooks.cells(rownumber,10).value=dw_1.getitemstring(rownumber -1,10)
    newoleworkbooks.cells(rownumber,11).value=dw_1.getitemstring(rownumber -1,11)
    newoleworkbooks.cells(rownumber,12).value=dw_1.getitemstring(rownumber -1,12)
    newoleworkbooks.cells(rownumber,13).value=dw_1.getitemstring(rownumber -1,13)
    newoleworkbooks.cells(rownumber,14).value=dw_1.getitemstring(rownumber -1,14)
    newoleworkbooks.cells(rownumber,15).value=dw_1.getitemstring(rownumber -1,15)
    newoleworkbooks.cells(rownumber,16).value=dw_1.getitemstring(rownumber -1,16)
    
next
newoleworkbooks.saveas("c:\excelfile.xls")
newoleobject.quit()
newoleobject.disconnectobject()
destroy newoleobject
destroy newoleworkbooks

我用的是 grid风格

板凳

免费下载郭宝利编写的N本PB电子图书,如果需要更多的PB电子图书到http://www.study01job.com网站,本站有郭宝利编写的多本电子图书供大家免费下载,并且还有很多关于PB学习的文章.

3 楼

没理由不谢谢。

4 楼

可以写成通用的函数,不过要看你用不用心了,呵呵!

5 楼

还真不错,学习了!

6 楼

pb提供源代码学习,网址www.study01job.com

我来回复

您尚未登录,请登录后再回复。点此登录或注册