[C#]namespaceDemos{usingAspose.Cells;usingAspose.Cells.Pivot;usingSystem;publicclassPivotAreaDemo{publicstaticvoidPivotAreaExample(){// Create a new workbookWorkbookworkbook=newWorkbook();Worksheetworksheet=workbook.Worksheets[0];// Add some data to the worksheetworksheet.Cells[0,0].Value="Fruit";worksheet.Cells[1,0].Value="Apple";worksheet.Cells[2,0].Value="Banana";worksheet.Cells[3,0].Value="Cherry";worksheet.Cells[0,1].Value="Year";worksheet.Cells[1,1].Value=2020;worksheet.Cells[2,1].Value=2021;worksheet.Cells[3,1].Value=2022;worksheet.Cells[0,2].Value="Amount";worksheet.Cells[1,2].Value=50;worksheet.Cells[2,2].Value=60;worksheet.Cells[3,2].Value=70;// Add a pivot table to the worksheetintpivotIndex=worksheet.PivotTables.Add("=Sheet1!A1:C4","E5","PivotTable1");PivotTablepivotTable=worksheet.PivotTables[pivotIndex];// Add fields to the pivot tablepivotTable.AddFieldToArea(PivotFieldType.Row,0);// FruitpivotTable.AddFieldToArea(PivotFieldType.Column,1);// YearpivotTable.AddFieldToArea(PivotFieldType.Data,2);// Amount// Create a PivotArea instancePivotAreapivotArea=newPivotArea(pivotTable);// Set properties of the PivotAreapivotArea.OnlyData=true;pivotArea.OnlyLabel=false;pivotArea.IsRowGrandIncluded=true;pivotArea.IsColumnGrandIncluded=true;pivotArea.AxisType=PivotFieldType.Row;pivotArea.RuleType=PivotAreaType.Normal;pivotArea.IsOutline=false;// Use the Select method to select a specific areapivotArea.Select(PivotFieldType.Row,0,PivotTableSelectionType.DataAndLabel);// Save the workbookworkbook.Save("PivotAreaExample.xlsx");}}}