2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

VBS 封裝Excel函數(shù)

 禁忌石 2019-10-23

Function Xls_CreateExcelApp(boolVisible)

On Error Resume Next

Dim excelShet

Set ExcelApp = CreateObject("Excel.Application")

If(boolVisible = "True") Then 

ExcelApp.Visible = True

ElseIf(boolVisible = "False") Then 

ExcelApp.Visible = False

Else

Xls_CreateExcelApp = "call the method params is incorrect"

End If 

'return 

Set Xls_CreateExcelApp = ExcelApp

'destory

Set ExcelApp = Nothing 

End Function

Function Xls_OpenWorkbook(ByRef ExcelApp,filepath)

On Error Resume Next

Set NewWorkbook = ExcelApp.Workbooks.Open(filepath)

Set Xls_OpenWorkbook = NewWorkbook

Set NewWorkbook = nothing

End Function

Function Xls_ActivateWorkbook(ByRef ExcelApp, strWorkBookName)

On Error Resume Next

ExcelApp.Workbooks(strWorkBookName).Activate

End Function

Function Xls_GetSheet(ByRef ExcelApp, strSheetName)

Err.Clear

Dim worksheet

On Error Resume Next

Set worksheet = ExcelApp.Worksheets.Item(strSheetName)

Set Xls_GetSheet = worksheet

Set worksheet  = nothing

End Function 

Function Xls_GetSheetUsedColumnsCount(strFileName, strSheetName)

Dim oExcel

Dim workbook

Dim worksheet

Set oExcel = Xls_CreateExcelApp("False")

Set workbook = Xls_OpenWorkbook(oExcel,strFileName)

Set worksheet = Xls_GetSheet(oExcel,strSheetName)

Xls_GetSheetUsedColumnsCount = worksheet.UsedRange.Columns.Count

oExcel.Quit

Set worksheet = Nothing

Set workbook = Nothing

Set oExcel = Nothing 

End Function

Function Xls_GetSheetUsedRowsCount(strFilename, strSheetName)

Dim oExcel, workbook, worksheet

Set oExcel = Xls_CreateExcelApp("False")

Set workbook = oExcel.Workbooks.Open(strFileName)

Set worksheet = Xls_GetSheet(oExcel,strSheetName)

Xls_GetSheetUsedRowsCount = worksheet.UsedRange.Rows.Count

oExcel.Quit

Set worksheet = Nothing

Set workbook = Nothing

Set oExcel = Nothing

End Function

Function Xls_GetCellvalue(ByRef ExcelSheet, intRow, intColumn)

'On Error Resume Next

Xls_GetCellvalue = ExcelSheet.Cells(intRow, intColumn)

End Function

Function Xls_GetSheetData2Array(strFileName, strSheetName)

Dim Columnscount, RowsCount

Columnscount = Xls_GetSheetUsedColumnsCount(strFileName,strSheetName)

RowsCount = Xls_GetSheetUsedRowsCount(strFileName, strSheetName)

Dim oExcel, workbook, worksheet

Set oExcel = Xls_CreateExcelApp("False")

Set workbook = oExcel.Workbooks.Open(strFileName)

Xls_ActivateWorkbook oExcel,strSheetName

Set worksheet = Xls_GetSheet(oExcel,strSheetName)

ReDim scriptItemArray(RowsCount-1,Columnscount-1)

Dim Actual

Actual = 0

For i=2 To RowsCount-1

number = Trim(Xls_GetCellvalue(worksheet,i,1))

If(IsEmpty(number) Or number = "" Or Not (IsNumeric(number))) Then

WSH.Echo number 

Exit For 

End If

Actual = Actual + 1

For j=1 To Columnscount-1

    scriptItemArray(i-2,j-1) = Trim(Xls_GetCellvalue(worksheet,i,j))

WSH.Echo Xls_GetCellvalue(worksheet,i,j)

Next 

Next

ReDim actualScriptItemArray(Actual-1, Columnscount-1)

For i=0 To Actual-1 

For j = 0 To Columnscount-1

actualScriptItemArray(i,j) = scriptItemArray(i,j)

Next

Next

oExcel.Quit

Set worksheet = Nothing

Set workbook =  Nothing

Set oExcel = Nothing 

Xls_GetSheetData2Array = actualScriptItemArray

End Function 

Dim strFileName, strSheetName

strFileName = "D:\VBS Libary\EOM\Case.xlsx"

strSheetName = "script"

Dim arrData

arrData = Xls_GetSheetData2Array(strFileName, strSheetName)

————————————————

版權(quán)聲明:本文為CSDN博主「erix1991」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權(quán)協(xié)議,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。

原文鏈接:https://blog.csdn.net/erix1991/article/details/17683433

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多