/** * XLSX document does not store empty cells and it might be an issue for formula calculations and etc. * So we need to create fake template cell for each empty cell. */ protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference, Cell> cellsForOneRowRange, List<Cell> templateCells) { if (oneRowRange.toCellReferences().size() != templateCells.size()) { final HashBiMap<CellReference, Cell> referencesToCells = HashBiMap.create(cellsForOneRowRange); for (CellReference cellReference : oneRowRange.toCellReferences()) { if (!cellsForOneRowRange.containsKey(cellReference)) { Cell newCell = Context.getsmlObjectFactory().createCell(); newCell.setV(null); newCell.setT(STCellType.STR); newCell.setR(cellReference.toReference()); templateCells.add(newCell); referencesToCells.put(cellReference, newCell); } } templateCells.sort((o1, o2) -> { CellReference cellReference1 = referencesToCells.inverse().get(o1); CellReference cellReference2 = referencesToCells.inverse().get(o2); return cellReference1.compareTo(cellReference2); }); } }
/** * XLSX document does not store empty cells and it might be an issue for formula calculations and etc. * So we need to create fake template cell for each empty cell. */ protected void createFakeTemplateCellsForEmptyOnes(Range oneRowRange, Map<CellReference, Cell> cellsForOneRowRange, List<Cell> templateCells) { if (oneRowRange.toCellReferences().size() != templateCells.size()) { final HashBiMap<CellReference, Cell> referencesToCells = HashBiMap.create(cellsForOneRowRange); for (CellReference cellReference : oneRowRange.toCellReferences()) { if (!cellsForOneRowRange.containsKey(cellReference)) { Cell newCell = Context.getsmlObjectFactory().createCell(); newCell.setV(null); newCell.setT(STCellType.STR); newCell.setR(cellReference.toReference()); templateCells.add(newCell); referencesToCells.put(cellReference, newCell); } } Collections.sort(templateCells, new Comparator<Cell>() { @Override public int compare(Cell o1, Cell o2) { CellReference cellReference1 = referencesToCells.inverse().get(o1); CellReference cellReference2 = referencesToCells.inverse().get(o2); return cellReference1.compareTo(cellReference2); } }); } }
newCell.setT(STCellType.STR); newCell.setV(formatValue(value, parameterName, fullParameterName)); } else if (value instanceof Boolean) { newCell.setT(STCellType.B); newCell.setV(String.valueOf(value)); } else if (value instanceof Number) { newCell.setT(STCellType.N); newCell.setV(String.valueOf(value)); } else if (value instanceof Date) { newCell.setT(STCellType.N); newCell.setV(String.valueOf(HSSFDateUtil.getExcelDate((Date) value))); } else { newCell.setT(STCellType.STR); newCell.setV(formatValue(value, parameterName, fullParameterName)); newCell.setT(STCellType.STR);
newCell.setT(STCellType.STR); newCell.setV(formatValue(value, parameterName, fullParameterName)); } else if (value instanceof Boolean) { newCell.setT(STCellType.B); newCell.setV(String.valueOf(value)); } else if (value instanceof Number) { newCell.setT(STCellType.N); newCell.setV(String.valueOf(value)); } else if (value instanceof Date) { newCell.setT(STCellType.N); newCell.setV(String.valueOf(HSSFDateUtil.getExcelDate((Date) value))); } else { newCell.setT(STCellType.STR); newCell.setV(formatValue(value, parameterName, fullParameterName)); newCell.setT(STCellType.STR);
public Cell createCell(org.xlsx4j.sml.ObjectFactory factory, String stringContent, int colNum, long rowNum) { Cell cell = factory.createCell(); cell.setT(STCellType.STR); cell.setV(stringContent); cell.setR(CellReference.convertNumToColString(colNum - 1) + "" + rowNum); cell.setS(0L); return cell; }
cellWithFormula.setF(null); cellWithFormula.setV("ERROR: Formula references to empty range"); cellWithFormula.setT(STCellType.STR);
cellWithFormula.setF(null); cellWithFormula.setV("ERROR: Formula references to empty range"); cellWithFormula.setT(STCellType.STR);