Convertir Excel en Imagen de Alta Resolución
Con la creciente prevalencia de pantallas de alta resolución, las imágenes generadas en la resolución predeterminada de 96 DPI a menudo aparecen borrosas y poco claras. Para asegurar claridad en pantallas de alta resolución, es esencial generar imágenes a una resolución DPI más alta. Aspose.Cells para Python via .NET ofrece la funcionalidad de configurar ImageOrPrintOptions.horizontal_resolution y ImageOrPrintOptions.vertical_resolution, permitiendo crear imágenes de alta calidad desde archivos de Excel que se ven nítidas en pantallas de alta resolución.
| from aspose.cells import Workbook | |
| from aspose.cells.drawing import ImageType | |
| from aspose.cells.rendering import ImageOrPrintOptions, SheetRender | |
| # 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") |