/** * @param id PivotDataSeparatedCell id that should be merged * @return first col index of all cells that should be merged by common id */ public int getFirstColById(String id) { int firstCol = Integer.MAX_VALUE; for (PivotDataSeparatedCell cell : cellsToMerged) { if (cell.getId().equals(id) && firstCol > cell.getIndexCol()) { firstCol = cell.getIndexCol(); } } return firstCol; }
/** * @param id PivotDataSeparatedCell id that should be merged * @return last col index of all cells that should be merged by common id */ public int getLastColById(String id) { int lastCol = 0; for (PivotDataSeparatedCell cell : cellsToMerged) { if (cell.getId().equals(id) && lastCol < cell.getIndexCol()) { lastCol = cell.getIndexCol(); } } return lastCol; }
protected int createAndAddSeparatedCells(PivotDataSeparatedCell separatedCell, List<PivotDataSeparatedCell> cellsRow) { List<PivotDataSeparatedCell> result = new ArrayList<>(); for (int i = 1; i < separatedCell.getColSpan(); i++) { PivotDataSeparatedCell cell = new PivotDataSeparatedCell(); cell.setId(separatedCell.getId()); cell.setIndexRow(separatedCell.getIndexRow()); cell.setIndexCol(separatedCell.getIndexCol() + i); cell.setColSpan(separatedCell.getColSpan()); cell.setRowSpan(separatedCell.getRowSpan()); cell.setValue(separatedCell.getValue()); cell.setType(separatedCell.getType()); cell.setBold(separatedCell.isBold()); result.add(cell); } cellsRow.add(separatedCell); cellsRow.addAll(result); cellsToMerged.add(separatedCell); cellsToMerged.addAll(result); return result.size(); }
public PivotDataSeparatedCell(PivotDataSeparatedCell cell) { this.id = cell.getId(); this.value = cell.getValue(); this.rowSpan = cell.getRowSpan(); this.colSpan = cell.getColSpan(); this.type = cell.getType(); this.isBold = cell.isBold(); this.indexCol = cell.getIndexCol(); this.indexRow = cell.getIndexRow(); }
HSSFCell hssfCell = hssfRow.createCell(cell.getIndexCol());