private static List<SpreadsheetCell> listNonEmptyCells(SpreadsheetCell[][] cells, SpreadsheetHeaderDefinition definition) { List<SpreadsheetCell> list = new ArrayList<SpreadsheetCell>(); int row = definition.getRow(); int col = definition.getColumn(); if (row >= 0) { for (int i = 0; i < cells[0].length; ++i) { if (!(cells[row][i].isEmpty())) { list.add(cells[row][i]); } } } else { for (int i = 0; i < cells.length; ++i) { if (!(cells[i][col].isEmpty())) { list.add(cells[i][col]); } } } return list; }
public ReturnSpreadsheetHeaderDefinition(SpreadsheetHeaderDefinition source, IOpenClass returnType) { super(source.getRow(), source.getColumn()); this.setType(source.getType()); for (SymbolicTypeDefinition var : source.getVars()) { addVarHeader(var); } this.returnType = returnType; }
private int calculateNonEmptyCells(SpreadsheetHeaderDefinition headerDefinition) { int fromRow = 0; int toRow = cellsHeaderExtractor.getHeight(); int fromColumn = 0; int toColumn = cellsHeaderExtractor.getWidth(); if (headerDefinition.isRow()) { fromRow = headerDefinition.getRow(); toRow = fromRow + 1; } else { fromColumn = headerDefinition.getColumn(); toColumn = fromColumn + 1; } int nonEmptyCellsCount = 0; for (int columnIndex = fromColumn; columnIndex < toColumn; columnIndex++) { for (int rowIndex = fromRow; rowIndex < toRow; rowIndex++) { ILogicalTable cell = LogicalTableHelper.mergeBounds(cellsHeaderExtractor.getRowNamesTable().getRow(rowIndex), cellsHeaderExtractor.getColumnNamesTable().getColumn(columnIndex)); String value = cell.getSource().getCell(0, 0).getStringValue(); if (value != null && value.trim().length() > 0) { nonEmptyCellsCount += 1; } } } return nonEmptyCellsCount; }