在windows form中加个button 单击这个button弹出openfiledialog
选好以后 在DataGird中输出EXCLE中的内容
完全代码 哪位能写个啊
另 能弄出来给分 但是我不知道怎么给分 所以写完代码 顺便写下给分方法
谢谢各位了
------解决方案--------------------
- VB.NET code
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim tb As DataTable = Nothing Using dlg As New OpenFileDialog With dlg .Filter = "*.xls|*.xls" .Multiselect = False If .ShowDialog = Windows.Forms.DialogResult.OK Then Dim db As New LzmTW.Data.ExcelDatabase(.FileName) Dim tables As DataTable = db.GetConnectionSchema("Tables") '只取第一个 Dim firstSheet As String = tables.Rows(0)("TABLE_NAME").ToString tb = db.GetDataTable("[" & firstSheet & "]") End If End With End Using If Not tb Is Nothing Then Me.DataGridView1.DataSource = tb End If End Sub End Class