I have an Excel file which has a million rows and 25 columns.
When I transfer the Excel data to a datatable
only 8000 to 9000 rows are being transferred to the datatable
. But the file has million rows.
I tried the below code:
<connectionStrings>
<!--Connect excel for bulk upload-->
<add name="Excel03ConString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"/>
<add name="Excel07+ConString" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR=YES'"/>
</connectionStrings>
connString = String.Format(connString, excelPath)
Using excel_con As New OleDbConnection(connString)
excel_con.Open()
Dim sheet1 As String = excel_con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing).Rows(0)("TABLE_NAME").ToString()
Dim dtExcelData As New DataTable()
dtExcelData.Columns.AddRange(New DataColumn(3) {New DataColumn("Document Type", GetType(String)), _
New DataColumn("Posting period", GetType(Decimal)), _
New DataColumn("Profit Center", GetType(String)) })
Using oda As New OleDbDataAdapter("SELECT * FROM [" + sheet1 + "]", excel_con)
oda.Fill(dtExcelData)
End Using
excel_con.Close()
End Using
How do I solve this?