EXATEL SHEET到DATAGRIDVIEW [英] EXCEL SHEET TO DATAGRIDVIEW

查看:51
本文介绍了EXATEL SHEET到DATAGRIDVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一张名为Ispis的excel表,其中2个表各有6列

在Table1之前是一些数据,并且Table1之间也有一些数据和表2

带有标题的表1从B16开始:G16,结束于B62:G62

表2,标题从B91开始:G16,结束于B118:G118

我想将Table1加载到DataGridview1,将Table2加载到Datagridview2

我的代码不起作用,因为table1之前有一些数据

我的代码

  Dim  MyConnection  As  System.Data.OleDb.OleDbConnection 
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = System.Data.OleDb.OleDbConnection( provider = Microsoft.Jet.OLEDB.4.0; Data Source ='C:\ Users\korisnik\Desktop\& File.Text& ';扩展属性= Excel 8.0;
MyCommand = System.Data.OleDb.OleDbDataAdapter( 从[Ispis]选择Sifra,Amount $];,MyConnection)
MyCommand.TableMappings.Add( Net-informations.com
DtSet = System.Data.DataSet
MyCommand.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables( 0





请帮助

解决方案

;,MyConnection)
MyCommand.TableMappings.Add( Net-informations.com
DtSet = System.Data.DataSet
MyCommand.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables( 0





请帮忙


< blockquote>您可以将范围包含在工作表名称的一部分中。类似于:



来自[Ispis


B16:G62]

Hi,
I have an excel sheet named"Ispis" with 2 tables each having 6 columns
Before Table1 are some data and also there are some data between Table1 and Table2
Table1 with headers starts at B16:G16 and ends at B62:G62
Table2 with headers starts at B91:G16 and ends at B118:G118
I want to load Table1 to DataGridview1 and Table2 to Datagridview2
My code does not work because there are some data before table1
My Code

Dim MyConnection As System.Data.OleDb.OleDbConnection
Dim DtSet As System.Data.DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\Users\korisnik\Desktop\" & File.Text & "';Extended Properties=Excel 8.0;")
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select Sifra, Amount from [Ispis$];", MyConnection)
MyCommand.TableMappings.Add("Table", "Net-informations.com")
DtSet = New System.Data.DataSet
MyCommand.Fill(DtSet)
DataGridView1.DataSource = DtSet.Tables(0)



Please help

解决方案

;", MyConnection) MyCommand.TableMappings.Add("Table", "Net-informations.com") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) DataGridView1.DataSource = DtSet.Tables(0)



Please help


You can include the range as part of the sheet name. Something like:

from [Ispis


B16:G62]


这篇关于EXATEL SHEET到DATAGRIDVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆