标题: 请教各位大神,小妹看不懂这两两个函数干什么用的,具体怎么调用? [打印本页] 作者: KERCHOW 时间: 2014-4-7 12:25 标题: 请教各位大神,小妹看不懂这两两个函数干什么用的,具体怎么调用? Function getTestdata( strFilePath,strSheetName,colNumber,flag,parmNumbers)
‘定义变量
Dim ExcelApp,ExcelBook,ExcelSheet,rowcount,colcount,array(),arra(),k
‘创建EXCEL程序,打开工作簿,设置当前活动sheet
Set ExcelApp = CreateObject(“Excel.Application”)
Set ExcelBook = ExcelApp.WorkBooks.Open(strFilePath)
Set ExcelSheet = ExcelBook.WorkSheets(strSheetName)
For i=0 To m-1
array(i,0)=arra(i)
For j=1 To parmNumbers
array(i,j)=ExcelSheet.cells(arra(i),j+colNumber)
Next
Next
‘返回值
getTestdata=array
‘关闭Ecxel
closeExcelSheet ExcelBook,ExcelApp,ExcelSheet
End Function
-------------------------------------------------------------------------------------------------------------
Sub setResultByArrdata(strFilePath,strSheetName,arrData,resultColname,arrResult)
Dim ExcelApp,ExcelBook,ExcelSheet,notNullNumber,intCol
‘创建EXCEL程序,打开工作簿,设置当前活动sheet
Set ExcelApp = CreateObject(“Excel.Application”)
Set ExcelBook = ExcelApp.WorkBooks.Open(strFilePath)
Set ExcelSheet = ExcelBook.WorkSheets(strSheetName)
‘取得EXCEL表共有几行、几列
rowcount =ExcelBook.ActiveSheet.UsedRange.Rows.Count
colcount=ExcelBook.ActiveSheet.UsedRange.Columns.Count
For i=1 To rowcount
If ExcelSheet.cells(i,intCol)“” Then
notNullNumber=notNullNumber+1
End If
Next
If notNullNumber=1 Then
For i=0 To UBound(arrResult)
ExcelSheet.cells(arrData(i,0),intCol).value = arrResult(i)
Next
Else
For i=0 To UBound(arrResult)
ExcelSheet.cells(arrData(i,0),colcount+1).value = arrResult(i)
Next
End If