将 Excel 转换为高分辨率图像
Contents
[
Hide
]
随着高分辨率屏幕的普及,默认 96 DPI 生成的图像常常显得模糊不清。为了确保在高分辨率屏幕上清晰显示,必须以更高的 DPI 生成图像。Aspose.Cells 提供了设置 ImageOrPrintOptions.HorizontalResolution 和 ImageOrPrintOptions.VerticalResolution 的功能,允许您从 Excel 文件创建高质量图像,在高分辨率显示屏上看起来清晰。
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// 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 | |
HorizontalResolution = 300, | |
VerticalResolution = 300, | |
// Set the image type | |
ImageType = ImageType.Png, | |
}; | |
// Get the worksheet | |
Worksheet sheet = workbook.Worksheets[0]; | |
// Create a SheetRender instance | |
SheetRender render = new SheetRender(sheet, options); | |
// Generate and save the image | |
render.ToImage(0, "output.png"); |