-
Notifications
You must be signed in to change notification settings - Fork 306
Formatting and styling
Jan Källman edited this page Aug 27, 2019
·
14 revisions
Cell styling is accessed by the Style property. You can easily style your spreadsheets by using the indexer of the Cells property decribed above. Lets say you want to set the numberformat of a range...
worksheet.Cells["C2:C5"].Style.Numberformat.Format = "#,##0";
...or you want to set the header row to bold and dark background and white font...
using (var range = worksheet.Cells[1, 1, 1, 5]) //Address "A1:A5"
{
range.Style.Font.Bold = true;
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(Color.DarkBlue);
range.Style.Font.Color.SetColor(Color.White);
}To see the some real code showing cell access and styling look into the sample project, for example sample 6
You can also create your own named styles, using the Workbook.Style.CreateNamedStyle method and the ExcelRange.StyleName property. As shown in sample 6...
//Add a HyperLink to the statistics sheet.
var namedStyle = pck.Workbook.Styles.CreateNamedStyle("HyperLink");
namedStyle.Style.Font.UnderLine = true;
namedStyle.Style.Font.Color.SetColor(Color.Blue);
ws.Cells["K13"].Hyperlink = new ExcelHyperLink("Statistics!A1", "Statistics");
ws.Cells["K13"].StyleName = "HyperLink";EPPlus Software AB - https://epplussoftware.com
- What is new in EPPlus 5+
- Breaking Changes in EPPlus 5
- Breaking Changes in EPPlus 6
- Breaking Changes in EPPlus 7
- Breaking Changes in EPPlus 8
- Addressing a worksheet
- Dimension/Used range
- Copying ranges/sheets
- Insert/Delete
- Filling ranges
- Sorting ranges
- Taking and skipping columns/rows
- Data validation
- Comments
- Freeze and Split Panes
- Header and Footer
- Hyperlinks
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- The ExcelRange.Text property
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles