Create Transparent Image of Excel Worksheet

Contents
[ ]

In the following worksheet image, transparency has not been applied. The cells with no fill colors are drawn white.

Output without transparency: the cell background is white
todo:image_alt_text

While, in the following worksheet image, transparency has been applied. The cells with no fill colors are transparent.

Output with transparency enabled
todo:image_alt_text

The following sample code generates a transparent image from an Excel worksheet.

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
# Source directory
sourceDir = RunExamples.Get_SourceDirectory()
# Output directory
outputDir = RunExamples.Get_OutputDirectory()
# Create workbook object from source file
wb = Workbook(sourceDir + "sampleCreateTransparentImage.xlsx")
# Apply different image or print options
imgOption = ImageOrPrintOptions()
imgOption.image_type = ImageType.PNG
imgOption.horizontal_resolution = 200
imgOption.vertical_resolution = 200
imgOption.one_page_per_sheet = True
# Apply transparency to the output image
imgOption.transparent = True
# Create image after apply image or print options
sr = SheetRender(wb.worksheets[0], imgOption)
sr.to_image(0, outputDir + "outputCreateTransparentImage.png")