/** * Create an instance of {@link CTCalcChain } * */ public CTCalcChain createCTCalcChain() { return new CTCalcChain(); }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
protected CTCalcChain getCalculationChain() { CTCalcChain calculationChain = null; try { CalcChain part = (CalcChain) result.getPackage().getParts().get(new PartName("/xl/calcChain.xml")); if (part != null) { try { calculationChain = part.getContents(); } catch (Docx4JException e) { throw new RuntimeException("Unable to get contents of part", e); } calculationChain.getC().clear(); } } catch (InvalidFormatException e) { //do nothing } return calculationChain; }
protected CTCalcChain getCalculationChain() { CTCalcChain calculationChain = null; try { CalcChain part = (CalcChain) result.getPackage().getParts().get(new PartName("/xl/calcChain.xml")); if (part != null) { calculationChain = part.getJaxbElement(); calculationChain.getC().clear(); } } catch (InvalidFormatException e) { //do nothing } return calculationChain; }
protected void updateFormula(Cell cellWithFormula, Range originalFormulaRange, Range formulaRange, CTCalcChain calculationChain, int formulaCount) { CTCellFormula formula = cellWithFormula.getF(); formula.setValue(formula.getValue().replace(originalFormulaRange.toRange(), formulaRange.toRange())); if (originalFormulaRange.isOneCellRange() && formulaRange.isOneCellRange()) { //here we check that there are no alpha-numeric symbols around the single reference String pattern = "(?<!\\w+)" + originalFormulaRange.toFirstCellReference() + "(?!\\w+)"; formula.setValue(formula.getValue().replaceAll(pattern, formulaRange.toFirstCellReference())); } if (calculationChain != null) { CTCalcCell calcCell = new CTCalcCell(); calcCell.setR(cellWithFormula.getR()); String sheetName = originalFormulaRange.getSheet(); Sheets sheets = template.getWorkbook().getSheets(); if (sheets != null && sheets.getSheet() != null) { for (Sheet sheet : sheets.getSheet()) { if (Objects.equals(sheet.getName(), sheetName)) { calcCell.setI((int) sheet.getSheetId()); break; } } } calculationChain.getC().add(calcCell); } }
/** * Create an instance of {@link CTCalcChain } * */ public CTCalcChain createCTCalcChain() { return new CTCalcChain(); }
/** * This method is invoked by the JAXB implementation on each instance when unmarshalling completes. * * @param parent * The parent object in the object tree. * @param unmarshaller * The unmarshaller that generated the instance. */ public void afterUnmarshal(Unmarshaller unmarshaller, Object parent) { setParent(parent); }
protected void updateFormula(Cell cellWithFormula, Range originalFormulaRange, Range formulaRange, CTCalcChain calculationChain, int formulaCount) { CTCellFormula formula = cellWithFormula.getF(); formula.setValue(formula.getValue().replace(originalFormulaRange.toRange(), formulaRange.toRange())); if (originalFormulaRange.isOneCellRange() && formulaRange.isOneCellRange()) { //here we check that there are no alpha-numeric symbols around the single reference String pattern = "(?<!\\w+)" + originalFormulaRange.toFirstCellReference() + "(?!\\w+)"; formula.setValue(formula.getValue().replaceAll(pattern, formulaRange.toFirstCellReference())); } if (calculationChain != null) { CTCalcCell calcCell = new CTCalcCell(); calcCell.setR(cellWithFormula.getR()); String sheetName = originalFormulaRange.getSheet(); Sheets sheets = template.getWorkbook().getSheets(); if (sheets != null && sheets.getSheet() != null) { for (Sheet sheet : sheets.getSheet()) { if (Objects.equals(sheet.getName(), sheetName)) { calcCell.setI((int) sheet.getSheetId()); break; } } } calculationChain.getC().add(calcCell); } }