I made the following code to load data from excel files to present it in a datagridview table, and it work fine, but it takes a long time to load data from big files (contains about 330,000 rows X 20 columns) and the loading process is not completed.
So I am looking for a faster way to load big size data to the datagridview table.
private void Load_Click(object sender, EventArgs e)
{
DataGrid_1.datasource = null;
DataGrid_1.datasource = Get_Data_Excel("C:\Test.xls","Select * from [Sheet1$]");
}
public static DataTable Get_Data_Excel(string File_Pth, string Qrr)
{
OleDbConnection con = new OleDbConnection(
"provider=Microsoft.ACE.OLEDB.12.0;data source="
+ File_Pth
+ ";Extended Properties=Excel 12.0;");
StringBuilder stbQuery = new StringBuilder();
stbQuery.Append(Qrr);
OleDbDataAdapter adp = new OleDbDataAdapter(stbQuery.ToString(), con);
DataSet dsXLS = new DataSet();
adp.Fill(dsXLS);
return dsXLS.Tables[0];
}