Enum PivotTableAutoFormatType

PivotTableAutoFormatType enumeration

Represents PivotTable auto format type.

public enum PivotTableAutoFormatType

Values

NameValueDescription
None0Represents None format type.
Classic1Represents Classic auto format type.
Report12Represents Report1 format type.
Report23Represents Report2 format type.
Report34Represents Report3 format type.
Report45Represents Report4 format type.
Report56Represents Report5 format type.
Report67Represents Report6 format type.
Report78Represents Report7 format type.
Report89Represents Report8 format type.
Report910Represents Report9 format type.
Report1011Represents Report10 format type.
Table112Represents Table1 format type.
Table213Represents Table2 format type.
Table314Represents Table3 format type.
Table415Represents Table4 format type.
Table516Represents Table5 format type.
Table617Represents Table6 format type.
Table718Represents Table7 format type.
Table819Represents Table8 format type.
Table920Represents Table9 format type.
Table1021Represents Table10 format type.

Examples

[C#]

namespace Demos
{
    using Aspose.Cells;
    using Aspose.Cells.Pivot;
    using System;

    public class PivotTableAutoFormatTypeDemo
    {
        public static void PivotTableAutoFormatTypeExample()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            Worksheet worksheet = workbook.Worksheets[0];

            // Add some sample data for the PivotTable
            worksheet.Cells[0, 0].Value = "Fruit";
            worksheet.Cells[0, 1].Value = "Year";
            worksheet.Cells[0, 2].Value = "Amount";
            worksheet.Cells[1, 0].Value = "Apple";
            worksheet.Cells[1, 1].Value = 2020;
            worksheet.Cells[1, 2].Value = 50;
            worksheet.Cells[2, 0].Value = "Banana";
            worksheet.Cells[2, 1].Value = 2020;
            worksheet.Cells[2, 2].Value = 60;
            worksheet.Cells[3, 0].Value = "Apple";
            worksheet.Cells[3, 1].Value = 2021;
            worksheet.Cells[3, 2].Value = 70;
            worksheet.Cells[4, 0].Value = "Banana";
            worksheet.Cells[4, 1].Value = 2021;
            worksheet.Cells[4, 2].Value = 80;

            // Add a PivotTable to the worksheet
            int pivotIndex = worksheet.PivotTables.Add("=Sheet1!A1:C5", "E3", "PivotTable1");
            PivotTable pivotTable = worksheet.PivotTables[pivotIndex];

            // Add fields to the PivotTable
            pivotTable.AddFieldToArea(PivotFieldType.Row, 0); // Fruit
            pivotTable.AddFieldToArea(PivotFieldType.Column, 1); // Year
            pivotTable.AddFieldToArea(PivotFieldType.Data, 2); // Amount

            // Set the auto format type for the PivotTable
            pivotTable.AutoFormatType = PivotTableAutoFormatType.Report1;

            // Save the workbook
            workbook.Save("PivotTableAutoFormatTypeExample.xlsx");
        }
    }
}

See Also