VB中如何调用EXCEL中的试看 充值 源码数据然后在VB中计算在VB中输出结果,能否提供一段源代码
下面的云棠源码程序段是从我设计的程序中复制出来的,你参考参考吧。EOS导出源码实际使用时还需要挑选修改。whmcs程序源码
'读取工作表的电气ERP 源码内容
Dim xlsAPP As Excel.Application '对EXCEL的引用
Dim ExcelIsRuning As Boolean 'EXCEL是否已经运行
Dim BookPay As Excel.Workbook
Dim SheetPay As Excel.Worksheet
Dim nRow As Long, nCol As Long
Dim xlsFile As String
'检查此文件是否还存在
xlsFile = Dir(txtFile.Text)
If xlsFile = "" Then
OpenExcel = False
lblTiShi.Caption = ""
Exit Function
Else
xlsFile = txtFile.Text
End If
'打开EXCEL程序
On Error Resume Next
If IsOpenning Then
BookPay.Close
Else
Set xlsAPP = GetObject(, "Excel.application")
If Err.Number <> 0 Then
Set xlsAPP = CreateObject("Excel.application")
Err.Clear
ExcelIsRuning = False
Else
ExcelIsRuning = True
End If
xlsAPP.DisplayAlerts = False '取消保存提示
End If
Set BookPay = xlsAPP.Workbooks.Open(xlsFile) '打开文件
'提取工作表名称
cboSheet.Clear
For nRow = 1 To BookPay.Sheets.Count
cboSheet.AddItem BookPay.Sheets(nRow).Name
Next
cboSheet.ListIndex = 0
For nRow = 1 To BookPay.Sheets.Count
If BookPay.Sheets(nRow).Name = cboSheet.Text Then
Set SheetPay = BookPay.Sheets(nRow)
Exit For
End If
Next
With MSHFlexGrid1
.Cols = SheetPay.UsedRange.Columns.Count + 1
For nCol = 1 To .Cols - 1
.TextMatrix(0, nCol) = nCol
Next
.Rows = SheetPay.UsedRange.Rows.Count + 1
.ColWidth(0) =
For nRow = 1 To SheetPay.UsedRange.Rows.Count
For nCol = 1 To SheetPay.UsedRange.Columns.Count
.TextMatrix(nRow, nCol) = SheetPay.Cells(nRow, nCol).Value
Next
Next
End With
lblTiShi.Caption = ""
2024-12-28 16:43
2024-12-28 16:42
2024-12-28 16:20
2024-12-28 15:41
2024-12-28 14:45