Convert xls and xlsx to Datatable in C#
问题 I am working in converting ths xls and xlsx to datatable in c#. I have used this code. public DataTable ReadDataExcel(string filepath) { FileStream stream = File.Open(filepath, FileMode.Open, FileAccess.Read); IExcelDataReader excelReader = ExcelReaderFactory.CreateBinaryReader(stream); excelReader.IsFirstRowAsColumnNames = true; DataSet result = excelReader.AsDataSet(); DataTable dt = new DataTable(); dt = result.Tables[0]; return dt; } In case of xls, its working fine. Whenever i used xlsx