国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
VBS 封裝Excel函數(shù)

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)載請附上原文出處鏈接及本聲明。

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

本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
探討通過VB向EXCEL傳輸數(shù)據(jù)的方法--
Excel 不打開文件提取數(shù)據(jù)
qtp之excel操作函數(shù)
C#(com組件)操作Excel讀寫
將數(shù)據(jù)從VisualBasic傳輸?shù)紼xcel的方法
C# 將數(shù)據(jù)導(dǎo)出到Excel匯總
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服