-
Notifications
You must be signed in to change notification settings - Fork 287
Function prefixes
Some newer functions in Excel needs to have prefixes when added to the Formula property via EPPlus. The most common prefix is "_xlfn.". EPPlus 7 and up will handle these attribute when calculating workbook that already contains them (as the workbook most likely was created by Excel), but when you add your own formulas via EPPlus v6 and below you need to be aware of this.
Here is an example:
sheet.Cells["A1"].Formula = "DAYS($B$1+1,H5)";
sheet.Calculate(); // this will result in a #NAME error in cell A1 when opened in Excel
The DAYS function is one of the functions that needs to have an _xlfn. prefix
sheet.Cells["A1"].Formula = "_xlfn.DAYS($B+1,H5)";
sheet.Calculate(); // this will work
Here is one page where Microsoft describes the prefixes.
From version 7 and up, EPPlus will add the prefixes for you if they are not included. You can see which functions EPPlus adds prefixes to in our supported functions list (column Prefix).
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
- 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
- Autofit columns
- Grouping and Ungrouping Rows and Columns
- Formatting and styling
- Conditional formatting
- Using Themes
- Working with custom named table- or slicer- styles