スライサーのレンダリング
Contents
[
Hide
]
可能な使用シナリオ
Aspose.Cellsはスライサーのレンダリングをサポートしています。ワークシートを画像に変換したり、ワークブックをPDFまたはHTML形式で保存すると、スライサーが適切にレンダリングされます。
スライサーのレンダリング
次のサンプルコードは、既存のスライサーを含む サンプル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"); |