long numcols , numrows , c, r
OLEObject xlapp , xlsub
int ret,coli
string colname,colname1
numcols = long(dw_data.Object.DataWindow.Column.Count)
numrows = dw_data.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]
string colnum //判断是A、B...或AA、AB...还是BA、BB、BC...
if integer(numcols) > 26 then
string colnumd,colnumd1
int numcols1,numcols2
numcols1 = mod(numcols,26)
numcols2 = numcols / 26
colnumd = char(numcols1 + 96)
colnumd1 = char(numcols2 + 96)
colnum ="'" + colnumd1 + colnumd + "'"
else
colnum = char(numcols + 96)
end if
xlsub.cells[1,1] = tabname //标题
xlsub.cells[1,1].HorizontalAlignment = 3
xlsub.cells[1,1].VerticalAlignment = 3
xlsub.cells[1,1].Font.Size = 20
xlsub.range("a1:" + colnum + "1").Merge()
string ls_colname
integer i
for i = 1 to numcols
//得到标题头的名字
ls_colname = dw_data.describe('#' + string(i) + ".name") + "_t"
xlsub.cells[2,i] = dw_data.describe(ls_colname + ".text")
next
//画表格线
string ls_range
ls_range = "A2:" + colnum + 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
//将数据写到EXECL
For c = 1 to numcols
For r = 1 to numrows
xlsub.cells[r + 2,c] = dw_data.object.data[r,c]
Next
Next
xlapp.Application.ActiveWorkbook.saved = false
xlApp.DisConnectObject()
Destroy xlapp
我不是来回答问题的。
我是来蹭分的。
你的问题太难,反正分也收不回来,有人答的上你就把分给他吧。
如果没人答的上。就把分给我吧。
这么多分浪费了怪可惜的。