public static int[] calculateRowOffsets(int height, IGridTable gt) { int[] rowOffset = new int[height + 1]; int offset = 0; for (int i = 0, cellHeight = 0; i < height; offset += cellHeight, ++i) { rowOffset[i] = offset; cellHeight = gt.getCell(0, offset).getHeight(); } rowOffset[height] = offset; return rowOffset; }
private void initCode() { code = table.getCell(column, row).getStringValue(); if (code == null) { code = ""; } }
private boolean isEmptyRow(IGridTable row) { int width = row.getWidth(); for (int i = 0; i < width; i++) { if (row.getCell(i, 0).getStringValue() != null) { return false; } } return true; }
@Override protected int getNumberToInsert(IGridTable table) { int cellHeight = getOriginalTable(table).getCell(col, beforeRow).getHeight(); int rowsToInsert = nRows; if (cellHeight > 1) { // merged cell rowsToInsert += cellHeight - 1; } return rowsToInsert; }
private boolean isEmptyRow(IGridTable row) { int width = row.getWidth(); for (int i = 0; i < width; i++) { if (row.getCell(i, 0).getStringValue() != null) { return false; } } return true; }
public String getTableName() { String header = table.getGridTable().getCell(0, 0).getStringValue(); String tableName = (header == null) ? "" : header; return tableName; }
@Override protected int getNumberToRemove(IGridTable table) { int cellHeight = getOriginalTable(table).getCell(col, startRow).getHeight(); int numberToRemove = nRows; if (cellHeight > 1) { // merged cell numberToRemove += cellHeight - 1; } return numberToRemove; }
@Override protected int getNumberToRemove(IGridTable table) { int cellWidth = getOriginalTable(table).getCell(startCol, row).getWidth(); int numberToInsert = nCols; if (cellWidth > 1) { // merged cell numberToInsert += cellWidth - 1; } return numberToInsert; }
private String getHeaderStr(int row, ILogicalTable table) { String headerStr = table.getRow(row) .getSource() .getCell(IDecisionTableConstants.INFO_COLUMN_INDEX, 0) .getStringValue(); if (headerStr == null) { return ""; } return headerStr.toUpperCase(); }
public static int calculateHeight(ILogicalTable table) { int height = table.getHeight(); int last = -1; for (int i = 0; i < height; i++) { String source = table.getRow(i).getSource().getCell(0, 0).getStringValue(); if (source != null && source.trim().length() != 0) { last = i; } } return last + 1; }
/** * @param tableProperties properties of the table that is going to be copied. * @return style of the properties section in table if exists. If no <code>NULL</code>. */ protected ICellStyle getPropertiesStyle(ITableProperties tableProperties) { ICellStyle propertiesStyle = null; ILogicalTable propertiesSection = tableProperties.getPropertiesSection(); if (propertiesSection != null) { propertiesStyle = propertiesSection.getSource().getCell(0, 0).getStyle(); } return propertiesStyle; }
private void compareCols(IGridTable grid1, IGridTable grid2, List<ICell> diff) { // compareRows is hard enough :) // let reuse it List<ICell> iDiff = new ArrayList<>(); compareRows(grid1.transpose(), grid2.transpose(), iDiff); // fix diff -- invert coordinates for (ICell c : iDiff) { diff.add(grid1.getCell(c.getRow(), c.getColumn())); } }
public static String[] extractElementsFromCommaSeparatedArray(ILogicalTable cell) { String[] tokens = null; String src = cell.getSource().getCell(0, 0).getStringValue(); if (src != null) { tokens = StringTool.splitAndEscape(src, ARRAY_ELEMENTS_SEPARATOR, ARRAY_ELEMENTS_SEPARATOR_ESCAPER); } return tokens; }
private int getWidthWithIgnoredEmptyCells(IGridTable table) { int width = table.getWidth(); while (width > 0) { for (int i = 0; i < table.getHeight(); i++) { if (table.getCell(width - 1, 0).getStringValue() != null) { return width; } } width--; } return 0; }
private void preprocessOpenlTable(IGridTable table, XlsSheetSourceCodeModule source) { String openlName = table.getCell(1, 0).getStringValue(); if (StringUtils.isNotBlank(openlName)) { openlName = openlName.trim(); } setOpenl(new OpenlSyntaxNode(openlName, new GridLocation(table), source)); }
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; }
public String[] getRowNames() { if (rowNames == null) { int height = getHeight(); rowNames = new String[height]; for (int row = 0; row < height; row++) { IGridTable nameCell = rowNamesTable.getRow(row).getColumn(0).getSource(); rowNames[row] = nameCell.getCell(0, 0).getStringValue(); } } return rowNames; }
private void initTableName() { if (table != null) { String name = table.getName(); if (StringUtils.isEmpty(name)) { // If table contains errors, it will not contain compiled name. Try to parse table header instead. String methodHeader = table.getGridTable().getCell(0, 0).getStringValue(); name = TableSyntaxNodeUtils.str2name(methodHeader, XlsNodeTypes.getEnumByValue(table.getType())); } tableTechnicalName = name; } }