OLEObject ole_object , ole_workbooks
ole_object = CREATE OLEObject
IF ole_object.ConnectToNewObject("Excel.Application") <> 0 THEN
MessageBox('OLE错误','OLE无法连接!')
return
END IF
ole_object.workbooks.add
ole_object.Visible = True
ole_workbooks = ole_object.Worksheets(1)
ole_workbooks.cells(1,1).value="任务号"
ole_workbooks.cells(1,2).value="次序"
ole_workbooks.cells(1,3).value="步数"
ole_workbooks.cells(1,4).value="机器号"
ole_workbooks.cells(1,5).value="开始时间"
ole_workbooks.cells(1,6).value="结束时间"
long l_row
for l_row = 2 to dw_1.rowcount()
ole_workbooks.cells(l_row,1).value=dw_1.getitemstring(l_row,1)
ole_workbooks.cells(l_row,2).value=dw_1.getitemnumber(l_row,2)
ole_workbooks.cells(l_row,3).value=dw_1.getitemnumber(l_row,3)
ole_workbooks.cells(l_row,4).value=dw_1.getitemnumber(l_row,4)
ole_workbooks.cells(l_row,5).value=dw_1.getitemtime(l_row,5)
ole_workbooks.cells(l_row,6).value=dw_1.getitemtime(l_row,6)
next
ole_workbooks.SaveAs ("d:\data.xls")
ole_object.quit()
Ole_Object.DisConnectObject()
Destroy Ole_Object
destroy ole_workbooks