|
恳请大家不吝赐教!个人编写代码如下,请问如何才能将Action1的Sheet数据输出到Excel中而不是Global的数据?系统默认对Global的数据进行读取操作且重复两次??
从DataTable中读取写入Excel
Dim xlApp,xlFile,xlSheet
Dim iRowCount,iLoop,jLoop,numAdd(6),record
Set xlApp=CreateObject("Excel.Application")
Set xlFile=xlApp.Workbooks.Open("D:\data.xls")
Set xlSheet=xlFile.Sheets("Sheet1")
iRowCount=DataTable.GetSheet("Global").GetRowCount '行数量
For iLoop = 1 To iRowCount
DataTable.SetCurrentRow(iLoop)
for jLoop = 1 To 6
numAdd(jLoop)= DataTable(jLoop,1)
xlSheet.Cells(iLoop,jLoop)=numAdd(jLoop)
Next
Next
xlFile.Save
xlFile.Close
xlApp.Quit
Set xlSheet = Nothing
Set xlSheet2 = Nothing
Set xlFile = Nothing
Set xlApp = Nothing |
|