oleobject newoleobject
newoleobject = create oleobject
if newoleobject.connecttonewobject( "Word.Application") 0 then
messageBOX("错误","OLE无法连接")
return
end if
newoleobject.Visible = true
long col_colnum ,col_rownum
constant long wdtablebehavior = 1
constant long wdatuofitfixed = 0
constant long wdCell = 12
String str_value
col_colnum = Long ( dw_1.object.datawindow.column.count )
col_rownum = dw_1.rowcount( ) + 1
newoleobject.documents.Add
newoleobject.activedocument.tables.add(newoleobject.Selection.range,col_rownum, col_colnum,wdtablebehavior,wdatuofitfixed)
string ls_colname
integer i ,j,k,l
for i = 1 to col_colnum
ls_colname = dw_1.describe( '#'+string(i)+".name")+"_t"
str_value = dw_1.describe( ls_colname + '.text')
newoleobject.selection.typetext(str_value)
newoleobject.selection.moveright(wdcell)
next
dw_1.setredraw( false)
newoleobject.selection.moveleft(wdcell)
for i = 2 to col_rownum
for j =1 to col_colnum
dw_1.scrolltorow(i - 1)
dw_1.setcolumn( j)
l = i - 1
//str_value = string( )
if j = 3 then
str_value = string (dw_1.getitemdecimal( l, j))
else
str_value = dw_1.getitemstring( l, j)
end if
newoleobject.selection.moveright(wdcell)
newoleobject.selection.typetext(str_value)
next
next
dw_1.setredraw( true )
constant long wdformatdocument = 0
newoleobject.activedocument.saveas("C:\sample.doc",0,false,"",true,"",false,false,false,false,false)
newoleobject.disconnectobject( )
destroy newoleobject