Package org.openxmlformats.schemas.spreadsheetml.x2006.main

Examples of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection


     * Flag indicating whether the sheet displays Automatic Page Breaks.
     *
     * @return <code>true</code> if the sheet displays Automatic Page Breaks.
     */
     public boolean getAutobreaks() {
        CTSheetPr sheetPr = getSheetTypeSheetPr();
        CTPageSetUpPr psSetup = (sheetPr == null || !sheetPr.isSetPageSetUpPr()) ?
                CTPageSetUpPr.Factory.newInstance() : sheetPr.getPageSetUpPr();
        return psSetup.getAutoPageBreaks();
    }
View Full Code Here


     * Flag indicating whether the sheet displays Automatic Page Breaks.
     *
     * @param value <code>true</code> if the sheet displays Automatic Page Breaks.
     */
    public void setAutobreaks(boolean value) {
        CTSheetPr sheetPr = getSheetTypeSheetPr();
        CTPageSetUpPr psSetup = sheetPr.isSetPageSetUpPr() ? sheetPr.getPageSetUpPr() : sheetPr.addNewPageSetUpPr();
        psSetup.setAutoPageBreaks(value);
    }
View Full Code Here

        }
        return sheetComments;
    }

    private CTPageSetUpPr getSheetTypePageSetUpPr() {
        CTSheetPr sheetPr = getSheetTypeSheetPr();
        return sheetPr.isSetPageSetUpPr() ? sheetPr.getPageSetUpPr() : sheetPr.addNewPageSetUpPr();
    }
View Full Code Here

     * @param password to set for protection. Pass <code>null</code> to remove protection
     */
    public void protectSheet(String password) {
         
      if(password != null) {
        CTSheetProtection sheetProtection = worksheet.addNewSheetProtection();
        sheetProtection.xsetPassword(stringToExcelPassword(password));
        sheetProtection.setSheet(true);
        sheetProtection.setScenarios(true);
        sheetProtection.setObjects(true);
      } else {
        worksheet.unsetSheetProtection();
      }
    }
View Full Code Here

     * @param password to set for protection. Pass <code>null</code> to remove protection
     */
    public void protectSheet(String password) {

      if(password != null) {
        CTSheetProtection sheetProtection = worksheet.addNewSheetProtection();
        sheetProtection.xsetPassword(stringToExcelPassword(password));
        sheetProtection.setSheet(true);
        sheetProtection.setScenarios(true);
        sheetProtection.setObjects(true);
      } else {
        worksheet.unsetSheetProtection();
      }
    }
View Full Code Here

    @Test
    public void protectSheet_lowlevel() {
        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sheet = wb.createSheet();
        CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
        assertNull("CTSheetProtection should be null by default", pr);
        String password = "Test";
        sheet.protectSheet(password);
        pr = sheet.getCTWorksheet().getSheetProtection();
        assertNotNull("CTSheetProtection should be not null", pr);
        assertTrue("sheet protection should be on", pr.isSetSheet());
        assertTrue("object protection should be on", pr.isSetObjects());
        assertTrue("scenario protection should be on", pr.isSetScenarios());
        String hash = String.valueOf(HexDump.shortToHex(PasswordRecord.hashPassword(password))).substring(2);
        assertEquals("well known value for top secret hash should be "+ hash, hash, pr.xgetPassword().getStringValue());

        sheet.protectSheet(null);
        assertNull("protectSheet(null) should unset CTSheetProtection", sheet.getCTWorksheet().getSheetProtection());
    }
View Full Code Here

    @Test
    public void protectSheet_lowlevel() {
        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sheet = wb.createSheet();
        CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
        assertNull("CTSheetProtection should be null by default", pr);
        String password = "Test";
        sheet.protectSheet(password);
        pr = sheet.getCTWorksheet().getSheetProtection();
        assertNotNull("CTSheetProtection should be not null", pr);
        assertTrue("sheet protection should be on", pr.isSetSheet());
        assertTrue("object protection should be on", pr.isSetObjects());
        assertTrue("scenario protection should be on", pr.isSetScenarios());
        String hash = String.valueOf(HexDump.shortToHex(PasswordRecord.hashPassword(password))).substring(2);
        assertEquals("well known value for top secret hash should be "+ hash, hash, pr.xgetPassword().getStringValue());

        sheet.protectSheet(null);
        assertNull("protectSheet(null) should unset CTSheetProtection", sheet.getCTWorksheet().getSheetProtection());
    }
View Full Code Here

     * @param password to set for protection. Pass <code>null</code> to remove protection
     */
    public void protectSheet(String password) {
         
      if(password != null) {
        CTSheetProtection sheetProtection = worksheet.addNewSheetProtection();
        sheetProtection.xsetPassword(stringToExcelPassword(password));
        sheetProtection.setSheet(true);
        sheetProtection.setScenarios(true);
        sheetProtection.setObjects(true);
      } else {
        worksheet.unsetSheetProtection();
      }
    }
View Full Code Here

     */
    @Override
    public void protectSheet(String password) {

        if(password != null) {
            CTSheetProtection sheetProtection = worksheet.addNewSheetProtection();
            sheetProtection.xsetPassword(stringToExcelPassword(password));
            sheetProtection.setSheet(true);
            sheetProtection.setScenarios(true);
            sheetProtection.setObjects(true);
        } else {
            worksheet.unsetSheetProtection();
        }
    }
View Full Code Here

    @Test
    public void protectSheet_lowlevel() {
        XSSFWorkbook wb = new XSSFWorkbook();
        XSSFSheet sheet = wb.createSheet();
        CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
        assertNull("CTSheetProtection should be null by default", pr);
        String password = "Test";
        sheet.protectSheet(password);
        pr = sheet.getCTWorksheet().getSheetProtection();
        assertNotNull("CTSheetProtection should be not null", pr);
        assertTrue("sheet protection should be on", pr.isSetSheet());
        assertTrue("object protection should be on", pr.isSetObjects());
        assertTrue("scenario protection should be on", pr.isSetScenarios());
        int hashVal = CryptoFunctions.createXorVerifier1(password);
        int actualVal = Integer.parseInt(pr.xgetPassword().getStringValue(),16);
        assertEquals("well known value for top secret hash should match", hashVal, actualVal);

        sheet.protectSheet(null);
        assertNull("protectSheet(null) should unset CTSheetProtection", sheet.getCTWorksheet().getSheetProtection());
    }
View Full Code Here

TOP

Related Classes of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.