public List <Crate> GetExcelFileDescriptionCrates(byte[] fileAsByteArray, string selectedFilePath, string sheetName = null, bool isRunTime = false) { var ext = Path.GetExtension(selectedFilePath); List <Crate> crates = new List <Crate>(); // Read file from repository // Fetch column headers in Excel file var headersArray = ExcelUtils.GetColumnHeaders(fileAsByteArray, ext, sheetName); var isFirstRowAsColumnNames = true; var hasFirstRowHeader = ExcelUtils.DetectContainsHeader(fileAsByteArray, ext, sheetName); // Fetch rows in Excel file var rowsDictionary = ExcelUtils.GetTabularData(fileAsByteArray, ext, isFirstRowAsColumnNames, sheetName); Crate tableCrate = Crate.FromContent(RunTimeCrateLabel, new StandardTableDataCM(isFirstRowAsColumnNames, new TableRowDTO[0])); // default one if (rowsDictionary != null && rowsDictionary.Count > 0) { var rows = ExcelUtils.CreateTableCellPayloadObjects(rowsDictionary, headersArray, isFirstRowAsColumnNames); if (rows != null && rows.Count > 0) { tableCrate = Crate.FromContent(RunTimeCrateLabel, new StandardTableDataCM(hasFirstRowHeader, rows)); var fieldsCrate = TabularUtilities.PrepareFieldsForOneRowTable(isFirstRowAsColumnNames, rows, headersArray); if (fieldsCrate != null) { crates.Add(fieldsCrate); } } } crates.Add(tableCrate); return(crates); }
private StandardTableDataCM CreateStandardTableCMFromExcelFile(byte[] excelFile, string excelFileExtension) { var rowsDictionary = ExcelUtils.GetTabularData(excelFile, excelFileExtension, false); if (rowsDictionary != null) { var rows = ExcelUtils.CreateTableCellPayloadObjects(rowsDictionary); if (rows != null) { return(new StandardTableDataCM { FirstRowHeaders = false, Table = rows }); } } return(null); }