public bool TryGetDataFile(int contentLength, string fileName, Stream inputStream, out IEnumerable <DataRow> dataRows, bool isFirstRowAsColumNames = true) { dataRows = new List <DataRow>(); if (contentLength > 0) { string fileExtension = System.IO.Path.GetExtension(fileName); if (".xls".Equals(fileExtension) || ".xlsx".Equals(fileExtension) || ".csv".Equals(fileExtension)) { IExcelDataReader dataReader = null; IEnumerable <string> sheets = ExcelExtension.GetWorksheetNames(inputStream, fileExtension, out dataReader, isFirstRowAsColumNames); if (!sheets.Any()) { return(false); } dataRows = ExcelExtension.GetData(sheets.First(), dataReader, fileExtension, isFirstRowAsColumNames, this.GetHeaders); if (dataRows != null) { return(true); } } } return(false); }