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 offers the functionality to set ImageOrPrintOptions.HorizontalResolution and ImageOrPrintOptions.VerticalResolution, allowing you to create high-quality images from Excel files that look sharp on high-resolution displays.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// Load the Excel file | |
Workbook workbook = new Workbook("input.xlsx"); | |
// Create an instance of ImageOrPrintOptions | |
ImageOrPrintOptions options = new ImageOrPrintOptions(); | |
// Set horizontal and vertical resolution to 300 DPI | |
options.setHorizontalResolution(300); | |
options.setVerticalResolution(300); | |
// Set the image type | |
options.setImageType(ImageType.PNG); | |
// Get the worksheet | |
Worksheet sheet = workbook.getWorksheets().get(0); | |
// Create a SheetRender instance | |
SheetRender render = new SheetRender(sheet, options); | |
// Generate and save the image | |
render.toImage(0, "output.png"); |