2014-03-28 98 views
0

我想從excel中讀取數據。想從excel讀取數據行到VB.NET

我有18列和行的數量可以非常從150至500。

讀我想表明它在網格視圖以及將其插入到數據庫同時數據之後。

我有一個代碼,它只能讀列,實際上這不是我的要求。

我想要明智的行。

enter code here 

For rCount = 4 To rCount 
       objValues = CType(exCell(rCount, 1), Excel.Range).Value() 
       If objValues <> Nothing Then 
        ' dtRecords.Columns.Add(objValues.ToString) 
        dtRecords.Rows.Add(objValues.ToString) 
        totalRecords += 1 
       End If 
       Exit For 
      Next 


      ds.Tables.Add(dtRecords) 
      If ds.Tables.Count > 0 Then 
       grvRecords.AutoGenerateColumns = True 
       grvRecords.DataSource = ds.Tables(0) 

      End If 

`

回答

0

如果你熟悉SQL,您可以使用ADO.NET從Excel中檢索數據。 請參閱:http://support.microsoft.com/kb/316934/en

+0

不,這不是我的要求,我需要從我的Excel中讀取行並將其插入SQl服務器。插入時,我會檢查這些行是否存在,根據標誌ll b返回到前端。 – jidh