1、打开VB-》在form1上增加一个command1按钮,双击command1按钮,把以下代码放入窗体内; 2、运行前,在菜单的选“工程”->“引用”->找到Microsoft Excel 12.0 Object Library->确定;然后才可以运行; 3、代码如下: Dim ExApp As New Excel.Application Dim Exb As Excel.Workbook Dim Exsh As Excel.Worksheet Dim arr(6, 6) As Integer '定义一... 1、打开VB-》在form1上增加一个command1按钮,双击command1按钮,把以下代码放入窗体内;
2、运行前,在菜单的选“工程”->“引用”->找到Microsoft Excel 12.0 Object Library->确定;然后才可以运行;
3、代码如下:
Dim ExApp As New Excel.Application
Dim Exb As Excel.Workbook
Dim Exsh As Excel.Worksheet
Dim arr(6, 6) As Integer '定义一个二维数组,数据类型为整数
ExApp.Workbooks.Open "c:\book1.xls" '打开EXEL文件,路径和文件名自己根据实际修改
Set Exb = ExApp.Workbooks(1)
Set Exsh = Exb.Worksheets("Sheet1")
For i = 1 To 6 '假设是读取A1:F6的6X6区域数据
For j = 1 To 6
arr(i, j) = Exsh.Cells(i, j)
Next j
Next i
'把自己需要对数组数据进一步处理的部分加进去...
ExApp.Workbooks.Close
ExApp.Quit
Set ExApp = Nothing 全部
If xlsApp.ActiveWorkbook.Sheets("sheet1").Cells(i, 1).Value - Text1.Text = 0 Then