Hey its very simple, you can use excel dll which provide you the feature to convert your excel or csv into dataset directly. Follow the below code:
string ext = Path.GetExtension(FileExport.FileName).ToLower();
Stream fileStream = new MemoryStream(FileExport.FileBytes);
IExcelDataReader excelReader;
if (ext.Trim() == ".xls")
{
excelReader = ExcelReaderFactory.CreateBinaryReader(fileStream);
}
else
{
excelReader = ExcelReaderFactory.CreateOpenXmlReader(fileStream);
}
excelReader.IsFirstRowAsColumnNames = true;
DataSet excelDataSet = excelReader.AsDataSet();
ExcelImportData = excelDataSet.Tables[0];
excelReader.Close();
Once the data came in dataset you can use it as the way you want. You can use a loop to extract the data row by row or column by column or you can directly save to another excel file.
you can download the excel dll fro here http://www.dllme.com/dll/files/microsoft_office_tools_excel_dll.html[^]
In case of any issue please let me know.