ImageOrPrintOptions kullanarak Çalışma Sayfalarından Görüntüleri Çıkarma
Contents
[
Hide
]
Microsoft Excel kullanıcıları, çalışma sayfalarına resim ekleyebilirler. Aspose.Cells for Python via .NET ile, Excel dosyalarından resimleri okuyabilir ve yerel diske kaydedebilirsiniz. Bu makale, nasıl yapılacağını gösterir.
Aşağıdaki örnek kod, Excel dosyasından resimleri çıkarmayı ve kaydetmeyi gösterir.
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 | |
# 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() | |
# Open a template Excel file | |
workbook = Workbook(sourceDir + "sampleExtractImagesFromWorksheets.xlsx") | |
# Get the first worksheet | |
worksheet = workbook.worksheets[0] | |
# Get the first Picture in the first worksheet | |
pic = worksheet.pictures[0] | |
# Set the output image file path | |
picformat = str(pic.image_type) | |
# Note: you may evaluate the image format before specifying the image path | |
# Define ImageOrPrintOptions | |
printoption = ImageOrPrintOptions() | |
# Specify the image format | |
printoption.image_type = ImageType.JPEG | |
# Save the image | |
pic.to_image(outputDir + "outputExtractImagesFromWorksheets.jpg", printoption) |