Convert Excel to High-Resolution Image
With the increasing prevalence of high-resolution screens, images generated at the default 96 DPI often appear blurry and unclear. To ensure clarity on high-resolution screens, it’s essential to generate images at a higher DPI. Aspose.Cells for Python via .NET offers the functionality to set ImageOrPrintOptions.horizontal_resolution and ImageOrPrintOptions.vertical_resolution, allowing you to create high-quality images from Excel files that look sharp on high-resolution displays.
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 the Excel file | |
workbook = Workbook("input.xlsx") | |
options = ImageOrPrintOptions() | |
options.horizontal_resolution = 300 | |
options.vertical_resolution = 300 | |
options.image_type = ImageType.PNG | |
# Create an instance of ImageOrPrintOptions | |
options = options | |
# Get the worksheet | |
sheet = workbook.worksheets[0] | |
# Create a SheetRender instance | |
render = SheetRender(sheet, options) | |
# Generate and save the image | |
render.to_image(0, "output.png") |