渲染切片器
Contents
[
Hide
]
可能的使用场景
Aspose.Cells 支持切片形状的渲染。如果将工作表转换为图像或将工作簿保存为 PDF 或 HTML 格式,您将看到切片器正确呈现。
渲染切片器
下面的示例代码加载示例 Excel 文件包含一个现有的切片器。它通过设置仅覆盖切片器的打印区域将工作表转换为图像。流动的图像是输出图像显示渲染的切片器。如您所见,切片器已正确呈现,看起来与示例 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 sample Excel file containing slicer. | |
Workbook wb = new Workbook("sampleRenderingSlicer.xlsx"); | |
// Access first worksheet. | |
Worksheet ws = wb.Worksheets[0]; | |
// Set the print area because we want to render slicer only. | |
ws.PageSetup.PrintArea = "B15:E25"; | |
// Specify image or print options, set one page per sheet and only area to true. | |
Aspose.Cells.Rendering.ImageOrPrintOptions imgOpts = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
imgOpts.HorizontalResolution = 200; | |
imgOpts.VerticalResolution = 200; | |
imgOpts.ImageType = Aspose.Cells.Drawing.ImageType.Png; | |
imgOpts.OnePagePerSheet = true; | |
imgOpts.OnlyArea = true; | |
// Create sheet render object and render worksheet to image. | |
Aspose.Cells.Rendering.SheetRender sr = new Aspose.Cells.Rendering.SheetRender(ws, imgOpts); | |
sr.ToImage(0, "outputRenderingSlicer.png"); |