Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xlsx to pdf data visualization Error #43

Open
dagudelo opened this issue Nov 19, 2019 · 1 comment
Open

xlsx to pdf data visualization Error #43

dagudelo opened this issue Nov 19, 2019 · 1 comment

Comments

@dagudelo
Copy link

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
Copy link
Collaborator

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants