从excel中读出文字显示到datagrid上

80酷酷网    80kuku.com

  datagrid|excel|显示|datagrid|excelDim myDataset As New DataSet
Dim myOleDbConnection As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=d:\2.xls;" & _
"Extended Properties=""Excel 8.0;""")
Dim myOleDbCommand As OleDbCommand = New OleDbCommand("SELECT * FROM [Sheet1$]", myOleDbConnection)
Dim myData As OleDbDataAdapter = New OleDbDataAdapter(myOleDbCommand)

myData.Fill(myDataset)

DataGrid1.DataSource = myDataset.Tables(0).DefaultView
DataGrid1.DataBind()


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: