how to add a progress bar or loading bar or time of loading data for this code ,it will be possible to use backgroundworker for it ,because we don't use loop
private void BtnBrowse_Click(object sender, EventArgs e)
{
using (OpenFileDialog openFileDialog = new OpenFileDialog() { Filter = "Excel 97-2003 Workbook|*.xls|Excel Workbook|*.xlsx" })
{
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
txtFilename.Text = openFileDialog.FileName;
using (var stream = File.Open(openFileDialog.FileName, FileMode.Open, FileAccess.Read))
{
using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
{
DataSet result = reader.AsDataSet(new ExcelDataSetConfiguration()
{
ConfigureDataTable = (_) => new ExcelDataTableConfiguration() { UseHeaderRow = true }
});
tableCollection = result.Tables;
cboSheet.Items.Clear();
foreach (DataTable table in tableCollection)
cboSheet.Items.Add(table.TableName);//add sheet to combobox
}
}
}
}
}