public String[] getColumnNames() { return buildArrayForHeaders(columnHeaders, cellsHeaderExtractor.getWidth()); }
public String[] getColumnNames() { if (columnNames == null) { int width = getWidth(); columnNames = new String[width]; for (int col = 0; col < width; col++) { IGridTable nameCell = columnNamesTable.getColumn(col).getRow(0).getSource(); columnNames[col] = nameCell.getCell(0, 0).getStringValue(); } } return columnNames; }
private void extractCellValues() { CellsHeaderExtractor cellsHeadersExtractor = componentsBuilder.getCellsHeadersExtractor(); int rowsCount = cellsHeadersExtractor.getHeight(); int columnsCount = cellsHeadersExtractor.getWidth(); for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++) { IBindingContext rowBindingContext = getRowContext(rowIndex); for (int columnIndex = 0; columnIndex < columnsCount; columnIndex++) { boolean found = false; for (SpreadsheetCell cell : extractedCellValues) { int row = cell.getRowIndex(); int column = cell.getColumnIndex(); if (row == rowIndex && columnIndex == column) { found = true; } } if (!found) { extractCellValue(rowBindingContext, rowIndex, columnIndex); } } } }
/** * Add to {@link SpreadsheetOpenClass} fields that are represented by spreadsheet cells. * * @param spreadsheetType open class of the spreadsheet */ public void addCellFields(SpreadsheetOpenClass spreadsheetType, boolean autoType) { IBindingContext generalBindingContext = componentsBuilder.getBindingContext(); CellsHeaderExtractor cellsHeadersExtractor = componentsBuilder.getCellsHeadersExtractor(); int rowsCount = cellsHeadersExtractor.getHeight(); int columnsCount = cellsHeadersExtractor.getWidth(); // create cells according to the size of the spreadsheet cells = new SpreadsheetCell[rowsCount][columnsCount]; // create the binding context for the spreadsheet level spreadsheetBindingContext = new SpreadsheetContext(generalBindingContext, spreadsheetType); for (int rowIndex = 0; rowIndex < rowsCount; rowIndex++) { for (int columnIndex = 0; columnIndex < columnsCount; columnIndex++) { // build spreadsheet cell SpreadsheetCell spreadsheetCell = buildCell(rowIndex, columnIndex, autoType); // init cells array with appropriate cell cells[rowIndex][columnIndex] = spreadsheetCell; // create and add field of the cell to the spreadsheetType addSpreadsheetFields(spreadsheetType, spreadsheetCell, rowIndex, columnIndex); } } }
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; }