/** * @return number of Conditional Formatting objects of the sheet */ public int getNumConditionalFormattings() { return _sheet.getCTWorksheet().sizeOfConditionalFormattingArray(); }
/* package */ boolean isSheetProtectionEnabled() { CTWorksheet ct = _sh.getCTWorksheet(); return (ct.isSetSheetProtection()); }
/** * removes a Conditional Formatting object by index * @param index of a Conditional Formatting object to remove */ public void removeConditionalFormatting(int index) { checkIndex(index); _sheet.getCTWorksheet().removeConditionalFormatting(index); }
private CTSheetProtection safeGetProtectionField() { CTWorksheet ct = _sh.getCTWorksheet(); if (!isSheetProtectionEnabled()) { return ct.addNewSheetProtection(); } return ct.getSheetProtection(); }
/** * gets Conditional Formatting object at a particular index * * @param index * of the Conditional Formatting object to fetch * @return Conditional Formatting object */ public XSSFConditionalFormatting getConditionalFormattingAt(int index) { checkIndex(index); CTConditionalFormatting cf = _sheet.getCTWorksheet().getConditionalFormattingArray(index); return new XSSFConditionalFormatting(_sheet, cf); }
private void setWorksheetOutlineLevelRow() { CTWorksheet ct = _sh.getCTWorksheet(); CTSheetFormatPr pr = ct.isSetSheetFormatPr() ? ct.getSheetFormatPr() : ct.addNewSheetFormatPr(); if(outlineLevelRow > 0) { pr.setOutlineLevelRow((short)outlineLevelRow); } }
public int addConditionalFormatting(CellRangeAddress[] regions, ConditionalFormattingRule[] cfRules) { if (regions == null) { throw new IllegalArgumentException("regions must not be null"); } for(CellRangeAddress range : regions) range.validate(SpreadsheetVersion.EXCEL2007); if (cfRules == null) { throw new IllegalArgumentException("cfRules must not be null"); } if (cfRules.length == 0) { throw new IllegalArgumentException("cfRules must not be empty"); } if (cfRules.length > 3) { throw new IllegalArgumentException("Number of rules must not exceed 3"); } CellRangeAddress[] mergeCellRanges = CellRangeUtil.mergeCellRanges(regions); CTConditionalFormatting cf = _sheet.getCTWorksheet().addNewConditionalFormatting(); List<String> refs = new ArrayList<>(); for(CellRangeAddress a : mergeCellRanges) refs.add(a.formatAsString()); cf.setSqref(refs); int priority = 1; for(CTConditionalFormatting c : _sheet.getCTWorksheet().getConditionalFormattingArray()){ priority += c.sizeOfCfRuleArray(); } for(ConditionalFormattingRule rule : cfRules){ XSSFConditionalFormattingRule xRule = (XSSFConditionalFormattingRule)rule; xRule.getCTCfRule().setPriority(priority++); cf.addNewCfRule().set(xRule.getCTCfRule()); } return _sheet.getCTWorksheet().sizeOfConditionalFormattingArray() - 1; }
/** * Set background color of the sheet tab * * @param colorIndex the indexed color to set, must be a constant from {@link IndexedColors} */ public void setTabColor(int colorIndex){ CTWorksheet ct = _sh.getCTWorksheet(); CTSheetPr pr = ct.getSheetPr(); if(pr == null) pr = ct.addNewSheetPr(); CTColor color = CTColor.Factory.newInstance(); color.setIndexed(colorIndex); pr.setTabColor(color); }
/** * Adds a copy of HSSFConditionalFormatting object to the sheet * <p>This method could be used to copy HSSFConditionalFormatting object * from one sheet to another. For example: * <pre> * HSSFConditionalFormatting cf = sheet.getConditionalFormattingAt(index); * newSheet.addConditionalFormatting(cf); * </pre> * * @param cf HSSFConditionalFormatting object * @return index of the new Conditional Formatting object */ public int addConditionalFormatting( ConditionalFormatting cf ) { XSSFConditionalFormatting xcf = (XSSFConditionalFormatting)cf; CTWorksheet sh = _sheet.getCTWorksheet(); sh.addNewConditionalFormatting().set(xcf.getCTConditionalFormatting().copy()); return sh.sizeOfConditionalFormattingArray() - 1; }
CTWorksheet ctWorksheet = xsheet.getCTWorksheet(); CTConditionalFormatting[] conditionalFormattingArray = ctWorksheet.getConditionalFormattingArray();
if (!getCTWorksheet().isSetOleObjects()) { return null; XmlCursor cur = getCTWorksheet().getOleObjects().newCursor(); try { cur.selectPath(xquery);
throw new POIXMLException("Failed to clone sheet", e); CTWorksheet ct = clonedSheet.getCTWorksheet(); if(ct.isSetLegacyDrawing()) { logger.log(POILogger.WARN, "Cloning sheets with comments is not yet supported.");
CTWorksheet cwb = sh.getCTWorksheet(); CTOleObjects oo = cwb.isSetOleObjects() ? cwb.getOleObjects() : cwb.addNewOleObjects();
/** * @return number of Conditional Formatting objects of the sheet */ public int getNumConditionalFormattings() { return _sheet.getCTWorksheet().sizeOfConditionalFormattingArray(); }
/** * @return number of Conditional Formatting objects of the sheet */ public int getNumConditionalFormattings() { return _sheet.getCTWorksheet().sizeOfConditionalFormattingArray(); }
/** * removes a Conditional Formatting object by index * @param index of a Conditional Formatting object to remove */ public void removeConditionalFormatting(int index) { checkIndex(index); _sheet.getCTWorksheet().getConditionalFormattingList().remove(index); }
private CTSheetProtection safeGetProtectionField() { CTWorksheet ct = _sh.getCTWorksheet(); if (!isSheetProtectionEnabled()) { return ct.addNewSheetProtection(); } return ct.getSheetProtection(); }
/** * gets Conditional Formatting object at a particular index * * @param index * of the Conditional Formatting object to fetch * @return Conditional Formatting object */ public XSSFConditionalFormatting getConditionalFormattingAt(int index) { checkIndex(index); CTConditionalFormatting cf = _sheet.getCTWorksheet().getConditionalFormattingArray(index); return new XSSFConditionalFormatting(_sheet, cf); }
/** * gets Conditional Formatting object at a particular index * * @param index * of the Conditional Formatting object to fetch * @return Conditional Formatting object */ public XSSFConditionalFormatting getConditionalFormattingAt(int index) { checkIndex(index); CTConditionalFormatting cf = _sheet.getCTWorksheet().getConditionalFormattingArray(index); return new XSSFConditionalFormatting(_sheet, cf); }
private POIXMLDocumentPart findLegacyDrawingPart(XSSFSheet sheet) { CTLegacyDrawing legacyDrawingHF = sheet.getCTWorksheet().getLegacyDrawingHF(); if (legacyDrawingHF != null) { String id = legacyDrawingHF.getId(); for (POIXMLDocumentPart relation : sheet.getRelations()) { if (relation instanceof XSSFVMLDrawing && relation.getPackageRelationship().getId().equals(id)) { return relation; } } } return null; }