Create Transparent Image of Excel Worksheet
Contents
[
Hide
]
Bazen, çalışma sayfanızın şeffaf bir resim olarak üretilmesini istersiniz. Tüm hücrelere şeffaflık uygulamak istersiniz, dolgu rengi olmayan hücreler dahil. Aspose.Cells for Python via .NET, şeffaflık uygulamak için ImageOrPrintOptions.transparent özelliği sağlar. Bu özellik false ise, dolgusu olmayan hücreler beyaz renkte çizilir, true ise, şeffaf olarak çizilir.
Aşağıdaki çalışma sayfası görüntüsünde şeffaflık uygulanmamıştır. Dolgu rengi olmayan hücreler beyaz olarak çizilmiştir.
Şeffaflık olmadan çıktı: hücre arka planı beyazdır |
---|
![]() |
Ancak aşağıdaki çalışma sayfası görüntüsünde şeffaflık uygulanmıştır. Dolgu rengi olmayan hücreler şeffaf olarak çizilmiştir.
Şeffaflık etkinleştirilmiş çıktı |
---|
![]() |
Aşağıdaki örnek kod, bir Excel çalışma sayfasından şeffaf bir görüntü oluşturur.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |