1.VB中如何调用EXCEL中的数据然后在VB中计算在VB中输出结果,能否提供一段源代码
VB中如何调用EXCEL中的preparestatement源码数据然后在VB中计算在VB中输出结果,能否提供一段源代码
下面的前端断点上传源码程序段是从我设计的程序中复制出来的,你参考参考吧。商业源码免费商城实际使用时还需要挑选修改。源码网站怎样赚钱
'读取工作表的git工具共享源码内容
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 = ""