aspose-cells / Aspose.Cells-for-Java

Aspose.Cells for Java examples, plugins and showcases
https://products.aspose.com/cells/java
MIT License
148 stars 102 forks source link

xlsx to pdf data visualization Error #43

Open dagudelo opened 4 years ago

dagudelo commented 4 years ago

Trying to print a Xlsx to pdf and removing all protection from excel file, the output pdf file doesn´t include the excel data

workbook = new Workbook(rutaExcel);

        vbaProject = workbook.getVbaProject();
        vbaProject.protect(false, "");

        WorksheetCollection worksheets = workbook.getWorksheets();
        Worksheet worksheet = worksheets.get(1);
        System.out.println("Esta protegido --> "+ worksheet.getProtection());

        Protection protection = worksheet.getProtection();

        // Restricting users to delete columns of the worksheet
        protection.setAllowDeletingColumn(false);

        // Restricting users to delete row of the worksheet
        protection.setAllowDeletingRow(false);

        // Restricting users to edit contents of the worksheet
        protection.setAllowEditingContent(false);

        // Restricting users to edit objects of the worksheet
        protection.setAllowEditingObject(false);

        // Restricting users to edit scenarios of the worksheet
        protection.setAllowEditingScenario(false);

        // Restricting users to filter
        protection.setAllowFiltering(false);

        // Allowing users to format cells of the worksheet
        protection.setAllowFormattingCell(true);

        // Allowing users to format rows of the worksheet
        protection.setAllowFormattingRow(true);

        // Allowing users to insert columns in the worksheet
        protection.setAllowInsertingColumn(true);

        // Allowing users to insert hyperlinks in the worksheet
        protection.setAllowInsertingHyperlink(true);

        // Allowing users to insert rows in the worksheet
        protection.setAllowInsertingRow(true);

        // Allowing users to select locked cells of the worksheet
        protection.setAllowSelectingLockedCell(true);

        // Allowing users to select unlocked cells of the worksheet
        protection.setAllowSelectingUnlockedCell(true);

        // Allowing users to sort
        protection.setAllowSorting(true);

        // Allowing users to use pivot tables in the worksheet
        protection.setAllowUsingPivotTable(true);

        // Saving the modified Excel file Excel XP format
        worksheet.unprotect();

        workbook.save(valorRuta, FileFormatType.XLSX);
        workbook.save(valorRutaPDF, SaveFormat.PDF);
        workbook.save(valorRutaPDF1, pdfSave);

        workbook1 = new Workbook(valorRuta);
        workbook1.save(rutaPDF, SaveFormat.PDF);
amjad-sahi commented 4 years ago

@dagudelo,

We need your template Xlsx file to evaluate your issue. So, kindly do upload to some file sharing service (e.g Dropbox, Google drive, any other, etc.) and share the Download link, so we could check your issue precisely.

Also, please note: 1) If you need to unprotect a worksheet, you may simply use Worksheet.unprotect method. 2) If you want to unprotect a protected workbook, you may use Workbook.unprotect method. 3) If you need to clear the password for an encrypted file, you may try workbook.getSettings().setPassword(null)