渲染切片器

可能的使用场景

Aspose.Cells支持对切片器形状进行渲染。如果将工作表转换为图像,或者将工作簿保存为PDF或HTML格式,您会看到切片器被正确地渲染。

渲染切片器

以下示例代码加载了包含现有切片器的sample Excel file。通过设置仅覆盖切片器的打印区域,将工作表转换为图像。下面的图像是显示了已被渲染的切片器的output image。您会看到,切片器已被正确地渲染,其外观与示例Excel文件中的相同。

todo:image_alt_text

示例代码

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