Interface ITableStyleElements
Represents Table Style Elements
Inherited Members
System.Collections.IEnumerable.GetEnumerator()
Assembly: Syncfusion.XlsIO.Base.dll
Syntax
public interface ITableStyleElements : IEnumerable
Properties
Count
Gets the table style Element count from table style elements list collection.
Declaration
Property Value
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
int count=tableStyleElements.Count;
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Item[ExcelTableStyleElementType]
Gets the table style element from table style elements list collection by using table style element type.
Declaration
ITableStyleElement this[ExcelTableStyleElementType tableStyleElementType] { get; }
Parameters
Property Value
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements= tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.HeaderRow);
tableStyleElement.BackColor=ExcelKnownColors.Red;
ITableStyleElement tableStyleElement1 = tableStyleElements[ExcelTableStyleElementType.HeaderRow];
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Item[Int32]
Gets the table style element from table style elements list collection by using index value.
Declaration
ITableStyleElement this[int index] { get; }
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Property Value
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements= tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.HeaderRow);
tableStyleElement.BackColor=ExcelKnownColors.Red;
ITableStyleElement tableStyleElement1 = tableStyleElements[0];
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Methods
Add(ExcelTableStyleElementType)
Create the table style element object to add the table style elements list collection and return by using table style element type.
Declaration
ITableStyleElement Add(ExcelTableStyleElementType tableStyleElementType)
Parameters
Returns
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Add(ITableStyleElement)
If check the this table style element is already exist in table style element list collection to return related table style element, else this table style element is add to table style element list collection and return.
Declaration
ITableStyleElement Add(ITableStyleElement tableStyleElement)
Parameters
Returns
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
tableStyleElement.BackColor=ExcelKnownColors.Blue;
ITableStyleElement tableStyleElementClone=tableStyleElement.Clone();
MemoryStream stream=new MemoryStream();
workbook.SaveAs(stream);
stream.Position=0;
workbook= application.Workbooks.Open(stream);
ITableStyles tableStyles1=workbook.TableStyles;
ITableStyle tableStyle1 = tableStyles1.Add("Table Style");
ITableStyleElements tableStyleElements1=tableStyle1.TableStyleElements;
ITableStyleElement tableStyleElement1=tableStyleElements1.Add(tableStyleElementClone);
workbook.Close();
}
Contains(ExcelTableStyleElementType)
True if table style element is exist in table style elements list collection. otherwise, False
Declaration
bool Contains(ExcelTableStyleElementType tableStyleElementType)
Parameters
Returns
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
bool check = tableStyleElements.Contains(ExcelTableStyleElementType.FirstColumn);
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Contains(ITableStyleElement)
True if table style element is exist in table style elements list collection. otherwise, False
Declaration
bool Contains(ITableStyleElement tableStyleElement)
Parameters
Returns
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
bool check = tableStyleElements.Contains(tableStyleElement);
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
Remove(ITableStyleElement)
Remove the table style element from table style elements list collection by using table style element object.
Declaration
void Remove(ITableStyleElement tableStyleElement)
Parameters
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
tableStyleElements.Remove(tableStyleElement);
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}
RemoveAt(Int32)
Remove the table style element from table style elements list collection using index value.
Declaration
Parameters
Type |
Name |
Description |
System.Int32 |
index |
|
Examples
using(ExcelEngine excelEngine = new ExcelEngine())
{
IApplication application = excelEngine.Excel;
IWorkbook workbook = application.Workbooks.Open("Sample.xlsx");
IWorksheet worksheet = workbook.Worksheets[0];
string name = "Table Style 4";
ITableStyles tableStyles = workbook.TableStyles;
ITableStyle tableStyle = tableStyles.Add(name);
ITableStyleElements tableStyleElements = tableStyle.TableStyleElements;
ITableStyleElement tableStyleElement = tableStyleElements.Add(ExcelTableStyleElementType.FirstColumn);
tableStyleElements.RemoveAt(0);
workbook.SaveAs("CustomTableStyle.xlsx");
workbook.Close();
}