以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  在foxtable中,申明一个range变量如何申明和引用  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=115073)

--  作者:有点甜
--  发布时间:2018/2/28 16:30:00
--  

既然用vba了,就不要再用xls了

 

Dim dlg As New OpenFileDialog
dlg.Filter = "Excel2003文件|*.xls;*.csv;*.xlsx"
Dim filename As String
If dlg.ShowDialog = DialogResult.OK Then \'如果用户单击了确定按钮
    If MessageBox.Show("是否导入" & FileName & "?", "请确 认!", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then
        Dim App As New MSExcel.Application
        Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(dlg.filename)
        Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
        Dim Rg As MSExcel.Range = Ws.UsedRange
        For i As Integer = 1 To rg.rows.count
            For j As Integer = 1 To rg.columns.count
                output.show(ws.cells(i,j).text)
            Next
        next
        App.Quit
       
    End If
End If

 

http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=106892&skin=0