Change Slicer Properties
Possible Usage Scenarios
There might be situations where you may want to change the properties of the Slicer such as placement or row height. Aspose.Cells provides you with the option to update these properties.
Change Slicer Properties
Please see the following sample code. It loads the sample Excel file that contains a table. It then creates the slicer based on the first column and changes its properties like row height, width, is printable, title, etc. It saves the workbook as outputChangeSlicerProperties.xlsx.
Sample Code
// 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); |