我的环境是pb8.0,把dw到给excel,当dw的列数小于26时,一切正常。当dw列数大于26时pb8就退出,数据也到不出来。代码如下:各位高手看看怎么回事?怎么修改?
long numcols,numrows,r,c
oleobject xlapp,xlsub
string colname,colname1,column
int ret
int numcols1,numcols2
string ls_colname
int i
string ls_range
numcols=long(dw_1.object.datawindow.column.count)
numrows=dw_1.rowcount()
xlapp=create oleobject
ret=xlapp.connecttonewobject("Excel.application")
if ret<0 then
messagebox("connect to excel failed",string(ret))
return
end if
xlapp.application.workbooks.add()
xlapp.application.visible=true
xlsub=xlapp.application.activeworkbook.worksheets[1]
if integer(numcols)>26 then
numcols1=numcols/26
numcols2=mod(numcols,26)
column="'" + char(numcols1 + 96) + char(numcols2 + 96) + "'"
else
column=char(numcols + 96)
end if
xlsub.cells[1,1]='请你自已设计你所喜欢的表头格式!'
xlsub.cells[1,1].horizontalalignment=3
xlsub.cells[1,1].verticalalignment=3
xlsub.cells[1,1].font.size=20
xlsub.range("a1:" + column + "1").merge()
for i=1 to numcols
ls_colname=dw_1.describe("#" + string(i) +".name") +"-t"
xlsub.cells[2,i]=dw_1.describe(ls_colname + ".text")
next
//画表格线
ls_range="a2:" + column + trim(string(numrows + 2))
xlsub.range(ls_range).borders(1).linestyle=1
xlsub.range(ls_range).borders(2).linestyle=1
xlsub.range(ls_range).borders(3).linestyle=1
xlsub.range(ls_range).borders(4).linestyle=1
for c=1 to numcols
for r=1 to numrows
xlsub.cells[r + 2,c]=dw_1.object.data[r,c]
next
next
xlapp.application.activeworkbook.saved=false
xlapp.application.quit
xlapp.disconnectobject()
destroy xlapp
------解决方案--------------------
column="'" + char(numcols1 + 96) + char(numcols2 + 96) + "'"
改成
column= char(numcols1 + 96) + char(numcols2 + 96)