做个窗口,放入一个表控件,做一个按钮测试:
Dim TableName as string = "窗口1_Table1"
Dim dlg As New OpenFileDialog '定义一个新的OpenFileDialog
dlg.Filter = "Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb"
If dlg.ShowDialog = DialogResult.OK Then '如果用户单击了确定按钮
Dim Book As New XLS.Book(dlg.FileName)
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Tables(TableName).StopRedraw()
Dim dtb As New DataTableBuilder("统计")
For n1 As Integer = 1 To Sheet.Cols.Count - 1
dtb.AddDef(Sheet(0, n1).Text, GetType(String), 32)
Next
Tables(TableName).DataSource = dtb.BuildDataSource
For n As Integer = 1 To Sheet.Rows.Count - 1
Dim bh As String = Sheet(n, 0).Text
Dim dr As Row = Tables(TableName).AddNew()
For m As Integer = 0 To Tables(TableName).Cols.Count - 1
dr(Tables(TableName).Cols(m)) = Sheet(n, m).Value
Next
Next
Tables(TableName).ResumeRedraw()