更改切片器属性
Contents
[
Hide
]
可能的使用场景
也许会出现您希望更改切片器的属性的情况,比如位置或行高等。Aspose.Cells为您提供了更新这些属性的选项。
更改切片器属性
请查看以下示例代码。它加载包含表的sample Excel file,然后基于第一列创建切片器,并更改其属性,如行高、宽度、是否可打印、标题等。将工作簿另存为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); |