转换Excel到高分辨率图像

Contents
[ ]

随着高分辨率屏幕的普及,以默认96 DPI生成的图像往往显得模糊不清。为了确保在高分辨率屏幕上的清晰度,必须以更高的DPI生成图像。Aspose.Cells提供设置 ImageOrPrintOptions.HorizontalResolutionImageOrPrintOptions.VerticalResolution 的功能,从而可以从Excel文件创建在高分辨率显示器上清晰锐利的高质量图像。

// 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");