Class TableStyleCollection

TableStyleCollection class

Represents all custom table styles.

public class TableStyleCollection : CollectionBase<TableStyle>

Properties

NameDescription
Capacity { get; set; }
Count { get; }
DefaultPivotStyleName { get; set; }Gets and sets the default style name of pivot table .
DefaultTableStyleName { get; set; }Gets and sets the default style name of the table.
Item { get; }Gets the table style by the index. (2 indexers)
Item { get; set; }

Methods

NameDescription
AddPivotTableStyle(string)Adds a custom pivot table style.
AddTableStyle(string)Adds a custom table style.
BinarySearch(TableStyle)
BinarySearch(TableStyle, IComparer<TableStyle>)
BinarySearch(int, int, TableStyle, IComparer<TableStyle>)
Clear()
Contains(TableStyle)
CopyTo(TableStyle[])
CopyTo(TableStyle[], int)
CopyTo(int, TableStyle[], int, int)
Exists(Predicate<TableStyle>)
Find(Predicate<TableStyle>)
FindAll(Predicate<TableStyle>)
FindIndex(Predicate<TableStyle>)
FindIndex(int, Predicate<TableStyle>)
FindIndex(int, int, Predicate<TableStyle>)
FindLast(Predicate<TableStyle>)
FindLastIndex(Predicate<TableStyle>)
FindLastIndex(int, Predicate<TableStyle>)
FindLastIndex(int, int, Predicate<TableStyle>)
GetBuiltinTableStyle(TableStyleType)Gets the builtin table style
GetEnumerator()
IndexOf(TableStyle)
IndexOf(TableStyle, int)
IndexOf(TableStyle, int, int)
LastIndexOf(TableStyle)
LastIndexOf(TableStyle, int)
LastIndexOf(TableStyle, int, int)
RemoveAt(int)

Examples

using System;
using Aspose.Cells;
using Aspose.Cells.Tables;

namespace AsposeCellsExamples
{
    public class TablesClassTableStyleCollectionDemo
    {
        public static void Run()
        {
            // Create a new workbook
            Workbook workbook = new Workbook();
            
            // Access the table style collection
            TableStyleCollection tableStyles = workbook.Worksheets.TableStyles;
            
            // Display default style names
            Console.WriteLine("Default Table Style: " + tableStyles.DefaultTableStyleName);
            Console.WriteLine("Default Pivot Style: " + tableStyles.DefaultPivotStyleName);
            
            // Change the default table style
            tableStyles.DefaultTableStyleName = "TableStyleMedium9";
            
            // Save the workbook
            workbook.Save("TableStylesDemo.xlsx");
            
            // Verify the change by loading the saved file
            Workbook verifyWorkbook = new Workbook("TableStylesDemo.xlsx");
            Console.WriteLine("New Default Table Style: " + 
                verifyWorkbook.Worksheets.TableStyles.DefaultTableStyleName);
        }
    }
}

See Also