public static void Main()
        {
            // Load sample Excel file containing pivot table.
            Workbook wb = new Workbook(sourceDir + "sampleCreateSlicerToPivotTable.xlsx");

            // Access first worksheet.
            Worksheet ws = wb.Worksheets[0];

            // Access first pivot table inside the worksheet.
            Aspose.Cells.Pivot.PivotTable pt = ws.PivotTables[0];

            // Add slicer relating to pivot table with first base field at cell B22.
            int idx = ws.Slicers.Add(pt, "B22", pt.BaseFields[0]);

            // Access the newly added slicer from slicer collection.
            Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[idx];

            // Save the workbook in output XLSX format.
            wb.Save(outputDir + "outputCreateSlicerToPivotTable.xlsx", SaveFormat.Xlsx);

            // Save the workbook in output XLSB format.
            wb.Save(outputDir + "outputCreateSlicerToPivotTable.xlsb", SaveFormat.Xlsb);

            Console.WriteLine("CreateSlicerToPivotTable executed successfully.");
        }
Example #2
0
        public static void Main()
        {
            // Load sample Excel file containing slicer.
            Workbook wb = new Workbook(sourceDir + "sampleUpdatingSlicer.xlsx");

            // Access first worksheet.
            Worksheet ws = wb.Worksheets[0];

            // Access the first slicer inside the slicer collection.
            Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[0];

            // Access the slicer items.
            Aspose.Cells.Slicers.SlicerCacheItemCollection scItems = slicer.SlicerCache.SlicerCacheItems;

            // Unselect 2nd and 3rd slicer items.
            scItems[1].Selected = false;
            scItems[2].Selected = false;

            // Refresh the slicer.
            slicer.Refresh();

            // Save the workbook in output XLSX format.
            wb.Save(outputDir + "outputUpdatingSlicer.xlsx", SaveFormat.Xlsx);

            Console.WriteLine("UpdatingSlicer executed successfully.");
        }
        public static void Main()
        {
            // Load sample Excel file containing slicer.
            Workbook wb = new Workbook(sourceDir + "sampleRemovingSlicer.xlsx");

            // Access first worksheet.
            Worksheet ws = wb.Worksheets[0];

            // Access the first slicer inside the slicer collection.
            Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[0];

            // Remove slicer.
            ws.Slicers.Remove(slicer);

            // Save the workbook in output XLSX format.
            wb.Save(outputDir + "outputRemovingSlicer.xlsx", SaveFormat.Xlsx);

            Console.WriteLine("RemovingSlicer executed successfully.");
        }
        public static void Main()
        {
            // Load sample Excel file containing slicer.
            Workbook wb = new Workbook(sourceDir + "sampleFormattingSlicer.xlsx");

            // Access first worksheet.
            Worksheet ws = wb.Worksheets[0];

            // Access the first slicer inside the slicer collection.
            Aspose.Cells.Slicers.Slicer slicer = ws.Slicers[0];

            // Set the number of columns of the slicer.
            slicer.NumberOfColumns = 2;

            // Set the type of slicer style.
            slicer.StyleType = Aspose.Cells.Slicers.SlicerStyleType.SlicerStyleLight6;

            // Save the workbook in output XLSX format.
            wb.Save(outputDir + "outputFormattingSlicer.xlsx", SaveFormat.Xlsx);

            Console.WriteLine("FormattingSlicer executed successfully.");
        }