Document Solutions for Excel, Java Edition | Document Solutions
File Operations / Export to PDF / Export Slicers
In This Topic
    Export Slicers
    In This Topic

    Slicers are visual filters that are used to filter data in Excel spreadsheets. You can filter the data by clicking on desired type of data in slicer.

    DsExcel supports the export of Excel spreadsheet containing a slicer to PDF document. So, if an Excel spreadsheet containing a slicer is exported to PDF, the resulting PDF will contain the applied slicer.

    Using Code

    Refer to the following example code to export slicers to PDF document.

    Java
    Copy Code
    // Fetch default worksheet
    IWorksheet worksheet = workbook.getWorksheets().get(0);
            
    // Set Data
    worksheet.getRange("A1:F16").setValue(sourceData);
    worksheet.getRange("A:F").setColumnWidth(15);
    
    ITable table = worksheet.getTables().add(worksheet.getRange("A1:F16"), true);
    table.getColumns().get(3).getDataBodyRange().setNumberFormat("$#,##0.00");
    // Create slicer cache for table
    ISlicerCache cache = workbook.getSlicerCaches().add(table, "Category", "categoryCache");
    
    // Add two slicers for Category column
    @SuppressWarnings("unused")
    ISlicer slicer1 = cache.getSlicers().add(workbook.getWorksheets().get("Sheet1"), "cate1", "Category", 300, 50,
            100, 200);
    
    // Or we can just open the Excel having slicers and then export it
    // workbook.Open("ExcelContaningSlicers.xlsx");
    
    // Saving workbook to pdf
    workbook.save("13-ConvertExcelSlicersToPDFExport.pdf");

    Limitations

    The following is not supported while exporting slicers to PDF documents: