[英]Reading from excel with OleDbDataAdapter some numeric cells coming in scientific notation?
[英]Reading between rows x & y from Excel sheet through OleDbDataAdapter
我想使用OleDbDataAdapter將Excel工作表讀取到DataTable中,但是,我只想要電子表格的一部分(“看起來像數據庫”的部分)。 到目前為止,這是我的代碼:
Dim xls As String = "...fn.xls"
Dim conn As OleDbConnection = New OleDbConnection("Provider=...")
Dim da As OleDbDataAdapter
Dim dt As DataTable = new DataTable
Dim sql As String
conn.Open()
sql = "SELECT * FROM [Sheet1$]" 'this is where I want between rows x & y
da = NewOleDbDataAdapter(sql, conn)
da.Fill(dt)
這可能嗎?
謝謝,洛根
看來您可以做兩件事:
命名一個范圍,然后從中選擇。
sql = "SELECT * FROM [RangeName]" ' does not end with $
要么
sql = "SELECT * FROM [Sheet1$A1:Z10]" ' sheetname$excelrange
我不知道RangeName位,但猜測行/單元格的細節
我的來源: http : //bytes.com/topic/c-sharp/answers/537809-c-oledb-issue
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.