تصدير ورقة العمل أو الرسم البياني إلى صورة بالعرض والارتفاع المطلوبين
Contents
[
Hide
]
يمكنك استخدام Aspose.Cells للبايثون via .NET لتصدير ورقة العمل أو المخطط الخاص بك إلى صورة بالحجم المطلوب. يوفر ImageOrPrintOptions.set_desired_size() طريقة لضبط العرض والارتفاع المطلوب للصورة المُصدرة. يتم تحديد العرض والارتفاع بوحدة البكسل.
الكود التالي يقوم بتصدير ورقة العمل إلى صورة بحجم 400x400.
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 | |
workbook = Workbook(sourceDir + "sampleWorksheetToImageDesiredSize.xlsx") | |
# Access first worksheet | |
worksheet = workbook.worksheets[0] | |
# Set image or print options we want one page per sheet. The image format is in png and desired dimensions are 400x400 | |
opts = ImageOrPrintOptions() | |
opts.one_page_per_sheet = True | |
opts.image_type = ImageType.PNG | |
opts.set_desired_size(400, 400, False) | |
# Render sheet into image | |
sr = SheetRender(worksheet, opts) | |
sr.to_image(0, outputDir + "outputWorksheetToImageDesiredSize.png") |