/** * Use this method to get the CTSheetProtection object for the specified worksheet, so you can set its * parameters as you see fit. * * @param worksheetPart * @return * @throws Xlsx4jException */ public CTSheetProtection getSheetProtection(WorksheetPart worksheetPart) throws Xlsx4jException { if (worksheetPart==null) throw new Xlsx4jException("Passed null WorksheetPart"); if (worksheetPart.getJaxbElement()==null) { worksheetPart.setJaxbElement(new Worksheet()); } CTSheetProtection sheetProtection = worksheetPart.getJaxbElement().getSheetProtection(); if (sheetProtection==null) { sheetProtection = new CTSheetProtection(); worksheetPart.getJaxbElement().setSheetProtection(sheetProtection); } // default settings sheetProtection.setSheet(true); sheetProtection.setSelectLockedCells(true); sheetProtection.setSelectUnlockedCells(true); return sheetProtection; }
/** * Use this method to get the CTSheetProtection object for the specified worksheet, so you can set its * parameters as you see fit. * * @param worksheetPart * @return * @throws Xlsx4jException */ public CTSheetProtection getSheetProtection(WorksheetPart worksheetPart) throws Xlsx4jException { if (worksheetPart==null) throw new Xlsx4jException("Passed null WorksheetPart"); if (worksheetPart.getJaxbElement()==null) { worksheetPart.setJaxbElement(new Worksheet()); } CTSheetProtection sheetProtection = worksheetPart.getJaxbElement().getSheetProtection(); if (sheetProtection==null) { sheetProtection = new CTSheetProtection(); worksheetPart.getJaxbElement().setSheetProtection(sheetProtection); } // default settings sheetProtection.setSheet(true); sheetProtection.setSelectLockedCells(true); sheetProtection.setSelectUnlockedCells(true); return sheetProtection; }