menu

Document Processing

Interface IPivotCellFormat - FileFormats API Reference | Syncfusion

    Show / Hide Table of Contents

    Interface IPivotCellFormat

    Represents Pivot Cell Format

    Namespace: Syncfusion.XlsIO
    Assembly: Syncfusion.XlsIO.Base.dll
    Syntax
    public interface IPivotCellFormat

    Properties

    BackColor

    Gets or sets the background color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors BackColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];      
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.BackColor = ExcelKnownColors.Red;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    BackColorRGB

    Gets and sets the back ground RGB color.

    Declaration
    Color BackColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.BackColorRGB = System.Drawing.Color.FromArgb(255, 255, 0, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    Bold

    Gets or sets a boolean value indicating whether the font is bold.

    Declaration
    bool Bold { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.Bold = true;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
      }

    BottomBorderColor

    Gets or sets the bottom border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors BottomBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.BottomBorderStyle=ExcelLineStyle.Thick;
          cellFormat.BottomBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    BottomBorderColorRGB

    Gets or sets RGB color to bottom border.

    Declaration
    Color BottomBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.BottomBorderStyle=ExcelLineStyle.Thick;
          cellFormat.BottomBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    BottomBorderStyle

    Gets or sets the bottom border line style.

    Declaration
    ExcelLineStyle BottomBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.BottomBorderStyle=ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    DiagonalBorderColor

    Gets or sets the diagonal border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors DiagonalBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.DiagonalBorderStyle=ExcelLineStyle.Thick;
          cellFormat.DiagonalBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    DiagonalBorderColorRGB

    Gets or sets the diagonal border color (System.Drawing.Color).

    Declaration
    Color DiagonalBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.DiagonalBorderStyle = ExcelLineStyle.Thick;
          cellFormat.DiagonalBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    DiagonalBorderStyle

    Gets / sets line style of the diagonal border.

    Declaration
    ExcelLineStyle DiagonalBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.DiagonalBorderStyle=ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    FontColor

    Gets or sets the Font color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors FontColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.FontColor=ExcelKnownColors.Red;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    FontColorRGB

    Gets or sets RGB color to font.

    Declaration
    Color FontColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.FontColorRGB=System.Drawing.Color.FromArgb(255, 0, 0, 255);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    FontName

    Gets or sets RGB color to font.

    Declaration
    string FontName { get; set; }
    Property Value
    Type
    System.String
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.FontName = "Arial";
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    FontSize

    Gets or sets RGB color to font.

    Declaration
    double FontSize { get; set; }
    Property Value
    Type
    System.Double
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.FontSize = 14;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    FormulaHidden

    Indicates whether formula is hidden.

    Declaration
    bool FormulaHidden { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
    
          //Set FormulaHidden
          cellFormat.FormulaHidden = true;
    
          //Set locked
          cellFormat.Locked = true;
    
          //Enable sheet protection
          worksheet.Protect("", ExcelSheetProtection.All);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    HorizontalAlignment

    Horizontal alignment.

    Declaration
    ExcelHAlign HorizontalAlignment { get; set; }
    Property Value
    Type
    ExcelHAlign
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set alignment
          cellFormat.HorizontalAlignment = ExcelHAlign.HAlignRight;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    HorizontalBorderColor

    Gets or sets the Horizontal Border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors HorizontalBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.HorizontalBorderStyle=ExcelLineStyle.Thick;
          cellFormat.HorizontalBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    HorizontalBorderColorRGB

    Gets or sets RGB color to horizontal border.

    Declaration
    Color HorizontalBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.HorizontalBorderStyle=ExcelLineStyle.Thick;
          cellFormat.HorizontalBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    HorizontalBorderStyle

    Gets or sets the Horizontal border line style.

    Declaration
    ExcelLineStyle HorizontalBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.HorizontalBorderStyle = ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    IndentLevel

    Indent level.

    Declaration
    int IndentLevel { get; set; }
    Property Value
    Type
    System.Int32
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set indent level
          cellFormat.IndentLevel = 2;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    Italic

    Gets or sets a boolean value indicating whether the font is italic.

    Declaration
    bool Italic { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.Italic = true;
    
          workbook.SaveAs("PivotFormat.xlsx");
    
          workbook.Close();
          excelEngine.Dispose();
    
      }

    LeftBorderColor

    Gets or sets the left border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors LeftBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.LeftBorderStyle=ExcelLineStyle.Thick;
          cellFormat.LeftBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    LeftBorderColorRGB

    Gets or sets RGB color to left border.

    Declaration
    Color LeftBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.LeftBorderStyle=ExcelLineStyle.Thick;
          cellFormat.LeftBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    LeftBorderStyle

    Gets or sets the left border line style.

    Declaration
    ExcelLineStyle LeftBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.LeftBorderStyle=ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    Locked

    Indicates whether cell with this XF is locked.

    Declaration
    bool Locked { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
    
          //Set FormulaHidden
          cellFormat.FormulaHidden = true;
    
          //Set locked
          cellFormat.Locked = true;
    
          //Enable sheet protection
          worksheet.Protect("", ExcelSheetProtection.All);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    NumberFormat

    Gets or sets number format of the conditional format rule.

    Declaration
    string NumberFormat { get; set; }
    Property Value
    Type
    System.String
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set number format
          cellFormat.NumberFormat = "#,##0.00_);[Red](#,##0.00)";
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    NumberFormatIndex

    Gets or sets number format index of the conditional format rule.

    Declaration
    ushort NumberFormatIndex { get; set; }
    Property Value
    Type
    System.UInt16
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");      
          //Set number format index
          cellFormat.NumberFormatIndex = 5;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    PatternColor

    Gets or sets the pattern color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors PatternColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.PatternStyle = ExcelPattern.DarkVertical;
          cellFormat.PatternColor = ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    PatternColorRGB

    Gets or sets RGB color to pattern.

    Declaration
    Color PatternColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.PatternStyle = ExcelPattern.DarkVertical;
          cellFormat.PatternColorRGB = System.Drawing.Color.FromArgb(255, 255, 0, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
      }

    PatternStyle

    Gets and sets the pattern style from pivot cell format.

    Declaration
    ExcelPattern PatternStyle { get; set; }
    Property Value
    Type
    ExcelPattern
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.PatternStyle=ExcelPattern.DarkVertical;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    ReadingOrder

    Text direction, the reading order for far east versions.

    Declaration
    ExcelReadingOrderType ReadingOrder { get; set; }
    Property Value
    Type
    ExcelReadingOrderType
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set reading order
          cellFormat.ReadingOrder = ExcelReadingOrderType.RightToLeft;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    RightBorderColor

    Gets or sets the right border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors RightBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.RightBorderStyle=ExcelLineStyle.Thick;
          cellFormat.RightBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    RightBorderColorRGB

    Gets or sets RGB color to right border.

    Declaration
    Color RightBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.RightBorderStyle=ExcelLineStyle.Thick;
          cellFormat.RightBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    RightBorderStyle

    Gets or sets the right border line style.

    Declaration
    ExcelLineStyle RightBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.RightBorderStyle=ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    Rotation

    Text rotation angle: 0 Not rotated 1-90 1 to 90 degrees counterclockwise 91-180 1 to 90 degrees clockwise 255 Letters are stacked top-to-bottom, but not rotated.

    Declaration
    int Rotation { get; set; }
    Property Value
    Type
    System.Int32
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set rotation
          cellFormat.Rotation = 40;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }
    Exceptions
    Type Condition
    System.ArgumentOutOfRangeException

    Thrown when value is more than 0xFF.

    ShrinkToFit

    True- Indicates that the contents are shrunk to fit into cell.

    Declaration
    bool ShrinkToFit { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set shrink to fit
          cellFormat.ShrinkToFit = true;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    StrikeThrough

    Gets or sets a boolean value indicating whether the font is Strike.

    Declaration
    bool StrikeThrough { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.StrikeThrough=true;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    TopBorderColor

    Gets or sets the Top Border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors TopBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.TopBorderStyle=ExcelLineStyle.Thick;
          cellFormat.TopBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    TopBorderColorRGB

    Gets or sets RGB color to Top border.

    Declaration
    Color TopBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.TopBorderStyle=ExcelLineStyle.Thick;
          cellFormat.TopBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    TopBorderStyle

    Gets or sets the Top border line style.

    Declaration
    ExcelLineStyle TopBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.TopBorderStyle=ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    Underline

    Gets or sets the underline type from the pivot cell format.

    Declaration
    ExcelUnderline Underline { get; set; }
    Property Value
    Type
    ExcelUnderline
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.Underline =ExcelUnderline.Single;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    VerticalAlignment

    Vertical alignment.

    Declaration
    ExcelVAlign VerticalAlignment { get; set; }
    Property Value
    Type
    ExcelVAlign
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set alignment
          cellFormat.VerticalAlignment = ExcelVAlign.VAlignCenter;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    VerticalBorderColor

    Gets or sets the Vertical Border color from predefined colors (ExcelKnownColors).

    Declaration
    ExcelKnownColors VerticalBorderColor { get; set; }
    Property Value
    Type
    ExcelKnownColors
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.VerticalBorderStyle=ExcelLineStyle.Thick;
          cellFormat.VerticalBorderColor=ExcelKnownColors.Green;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    VerticalBorderColorRGB

    Gets or sets RGB color to Vertical border.

    Declaration
    Color VerticalBorderColorRGB { get; set; }
    Property Value
    Type
    System.Drawing.Color
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.VerticalBorderStyle=ExcelLineStyle.Thick;
          cellFormat.VerticalBorderColorRGB=System.Drawing.Color.FromArgb(255, 0, 255, 0);
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    VerticalBorderStyle

    Gets or sets the Vertical border line style.

    Declaration
    ExcelLineStyle VerticalBorderStyle { get; set; }
    Property Value
    Type
    ExcelLineStyle
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          cellFormat.VerticalBorderStyle = ExcelLineStyle.Thick;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }

    WrapText

    True - Indicates that text is wrapped at right border.

    Declaration
    bool WrapText { get; set; }
    Property Value
    Type
    System.Boolean
    Examples
        using(ExcelEngine excelEngine = new ExcelEngine())
        {
          IApplication application = excelEngine.Excel;
          IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
          IWorksheet worksheet = workbook.Worksheets[0];
    
          IPivotTable pivotTable = worksheet.PivotTables[0];
          //Get the cell format for "A1" pivot range.
          IPivotCellFormat cellFormat = pivotTable.GetCellFormat("A1");
          //Set wrap text
          cellFormat.WrapText = true;
    
          workbook.SaveAs("PivotFormat.xlsx");
          workbook.Close();
          excelEngine.Dispose();
    
      }
    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved