スライサープロパティを変更する
Contents
[
Hide
]
可能な使用シナリオ
配置や行の高さなどスライサーのプロパティを変更したい場合があります。Aspose.Cellsでは、これらのプロパティを更新するオプションを提供しています。
スライサープロパティを変更する
次のサンプルコードをご覧ください。最初の列を含むサンプルExcelファイルを読み込み、その後、高さ、幅、印刷可能、タイトルなどのプロパティを変更したスライサーを作成します。ワークブックをoutputChangeSlicerProperties.xlsxとして保存します。
サンプルコード
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 a table. | |
Workbook workbook = new Workbook(sourceDir + "sampleCreateSlicerToExcelTable.xlsx"); | |
// Access first worksheet. | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access first table inside the worksheet. | |
ListObject table = worksheet.ListObjects[0]; | |
// Add slicer | |
int idx = worksheet.Slicers.Add(table, 0, "H5"); | |
Slicer slicer = worksheet.Slicers[idx]; | |
slicer.Placement = PlacementType.FreeFloating; | |
slicer.RowHeightPixel = 50; | |
slicer.WidthPixel = 500; | |
slicer.Title = "Aspose"; | |
slicer.AlternativeText = "Alternate Text"; | |
slicer.IsPrintable = false; | |
slicer.IsLocked = false; | |
// Refresh the slicer. | |
slicer.Refresh(); | |
// Save the workbook in output XLSX format. | |
workbook.Save(outputDir + "outputChangeSlicerProperties.xlsx", SaveFormat.Xlsx); |