newCell.setV(""); return; newCell.setV(""); return; 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.setV(value);
newCell.setV(""); return; newCell.setV(""); return; 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.setV(value);
/** * 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); } }); } }
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; }
} else { cellWithFormula.setF(null); cellWithFormula.setV("ERROR: Formula references to empty range"); cellWithFormula.setT(STCellType.STR);
} else { cellWithFormula.setF(null); cellWithFormula.setV("ERROR: Formula references to empty range"); cellWithFormula.setT(STCellType.STR);
@Override public void inlineToXlsx(SpreadsheetMLPackage pkg, WorksheetPart worksheetPart, Cell newCell, Object paramValue, Matcher matcher) { try { Image image = new Image(paramValue, matcher); if (image.isValid()) { BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, worksheetPart, image.imageContent); CTOneCellAnchor anchor = new CTOneCellAnchor(); anchor.setFrom(new CTMarker()); CellReference cellReference = new CellReference("", newCell.getR()); anchor.getFrom().setCol(cellReference.getColumn() - 1); anchor.getFrom().setRow(cellReference.getRow() - 1); anchor.setExt(new CTPositiveSize2D()); anchor.getExt().setCx(XlsxUtils.convertPxToEmu(image.width)); anchor.getExt().setCy(XlsxUtils.convertPxToEmu(image.height)); newCell.setV(null); putImage(worksheetPart, pkg, imagePart, anchor); } } catch (Exception e) { throw new ReportFormattingException("An error occurred while inserting bitmap to xlsx file", e); } }
@Override public void inlineToXlsx(SpreadsheetMLPackage pkg, WorksheetPart worksheetPart, Cell newCell, Object paramValue, Matcher matcher) { try { Image image = new Image(paramValue, matcher); if (image.isValid()) { BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(pkg, worksheetPart, image.imageContent); CTOneCellAnchor anchor = new CTOneCellAnchor(); anchor.setFrom(new CTMarker()); CellReference cellReference = new CellReference("", newCell.getR()); anchor.getFrom().setCol(cellReference.getColumn() - 1); anchor.getFrom().setRow(cellReference.getRow() - 1); anchor.setExt(new CTPositiveSize2D()); anchor.getExt().setCx(XlsxUtils.convertPxToEmu(image.width)); anchor.getExt().setCy(XlsxUtils.convertPxToEmu(image.height)); newCell.setV(null); putImage(worksheetPart, pkg, imagePart, anchor); } } catch (Exception e) { throw new ReportFormattingException("An error occurred while inserting bitmap to xlsx file", e); } }