Rendering Slicer

Possible Usage Scenarios

Aspose.Cells for Python via .NET supports the rendering of slicer shape. If you convert your worksheet into an image or you save your workbook to PDF or HTML formats, you will see, slicers are rendered properly.

How to Render Slicer Using Aspose.Cells for Python Excel Library

The following sample code loads the sample Excel file that contains an existing slicer. It converts the worksheet into an image by setting the print area that covers only the slicer. The flowing image is the output image that shows the rendered slicer. As you can see, slicer has been rendered properly and it looks the same as in the sample Excel file.

todo:image_alt_text

Sample Code

from aspose.cells import Workbook
from aspose.cells.drawing import ImageType
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Load sample Excel file containing slicer.
wb = Workbook("sampleRenderingSlicer.xlsx")
# Access first worksheet.
ws = wb.worksheets[0]
# Set the print area because we want to render slicer only.
ws.page_setup.print_area = "B15:E25"
# Specify image or print options, set one page per sheet and only area to true.
imgOpts = ImageOrPrintOptions()
imgOpts.horizontal_resolution = 200
imgOpts.vertical_resolution = 200
imgOpts.image_type = ImageType.PNG
imgOpts.one_page_per_sheet = True
imgOpts.only_area = True
# Create sheet render object and render worksheet to image.
sr = SheetRender(ws, imgOpts)
sr.to_image(0, "outputRenderingSlicer.png")