DatasetStyle
Definition
Namespace: Surya.Ab.Export.Client.Models Assembly: Surya.Ab.Export.dll
It holds all style related properties for a Dataset.
public class DatasetStyle : ItemStyle
Inheritance ItemStyle -> DatasetStyle
Properties
Name | Definition |
---|---|
RowStyles | Represents style properties for rows of the table |
ColumnStyles | Represents style properties for columns of the table |
CellStyles | Represents style properties for cells of the table |
note
Row index of a Dataset always starts from 0 where 0th row represents Header of the table. For column, index starts from 1.
Structure
public class DatasetStyle : ItemStyle
{
public Dictionary<int, AbStyle>? RowStyles { get; set; } = default;
public Dictionary<int, AbStyle>? ColumnStyles { get; set; } = default;
public Dictionary<(int, int), AbStyle>? CellStyles { get; set; } = default;
}
Example
// Get instance of DatasetStyleBuilder
var datasetStyleBuilder = serviceProvider.GetRequiredService<IDatasetStyleBuilder>();
// Build Dataset style
var datasetStyle = datasetStyleBuilder
.HeaderStyle(new AbStyle()
{
FontSize = 20,
BackgroundColor = Color.LemonChiffon,
Color = Color.Purple,
TextAlign = new AbAlignment()
{
HorizontalAlignment = AbHorizontalAlignment.Center
}
})
.TableHeaderStyle(new AbStyle()
{
FontSize = 12,
BackgroundColor = Color.BlanchedAlmond,
Color = Color.Red,
TextAlign = new AbAlignment()
{
HorizontalAlignment = AbHorizontalAlignment.Left
},
CellBorder = new AbCellBorder()
{
TopBorder = new AbBorder(AbBorderStyleValues.Thick, Color.LightGray)
}
})
.BodyStyle(new AbStyle()
{
FontSize = 10,
Color = Color.DarkGoldenrod,
TextAlign = new AbAlignment()
{
HorizontalAlignment = AbHorizontalAlignment.Left
},
CellBorder = new AbCellBorder()
{
TopBorder = new AbBorder(AbBorderStyleValues.Thick, Color.LightGray),
BottomBorder = new AbBorder(AbBorderStyleValues.Thick, Color.LightGray),
LeftBorder = new AbBorder(AbBorderStyleValues.Thick, Color.Purple),
RightBorder = new AbBorder(AbBorderStyleValues.Thick, Color.Purple),
}
})
.FooterStyle(new AbStyle()
{
FontSize = 10,
BackgroundColor = Color.LemonChiffon,
Color = Color.Purple,
TextAlign = new AbAlignment()
{
HorizontalAlignment = AbHorizontalAlignment.Left
}
})
.RowStyles(row => row
.RowStyle(1, new AbStyle() { Color = Color.OrangeRed })
.RowStyle(3, new AbStyle() { FontWeight = FontWeight.Bold, TextDecorationLine = TextDecorationLine.UnderLine }))
.ColumnStyles(col => col
.ColumnStyle(1, new AbStyle() { Color = Color.Purple })
.ColumnStyle(3, new AbStyle() { FontWeight = FontWeight.Regular, TextDecorationLine = TextDecorationLine.LineThrough }))
.CellStyles(col => col
.CellStyle(0, 1, new AbStyle() { Width = 100, BackgroundColor = Color.OrangeRed }) //TableHeader 1st cell/col
.CellStyle(1, 2, new AbStyle() { Color = Color.PapayaWhip })
.CellStyle(3, 3, new AbStyle() { FontWeight = FontWeight.Bold, TextDecorationLine = TextDecorationLine.UnderLine, BackgroundColor = Color.LemonChiffon }))
.Build();