-
Notifications
You must be signed in to change notification settings - Fork 297
Precision as Displayed
Jan Källman edited this page Aug 20, 2024
·
3 revisions
From EPPlus version 7.3, Precision as Displayed is supported by setting the property ExcelWorkbook.FullPrecision to false.
When using Precision as displayed, EPPlus rounds all numeric cell values according to the number format.
This affects both cell values and formula results.
using (var p = new ExcelPackage())
{
var ws = p.Workbook.Worksheets.Add("Sheet1");
ws.Cells["A1"].Value = 123.456789;
ws.Cells["A2"].Value = 987.654321;
ws.Cells["A3"].Formula = "SUM(A1:A2)";
ws.Cells["A1:A3"].Style.Numberformat.Format = "#,##0.00";
p.Workbook.FullPrecision = false; //This will round the values in A1 and A2 according to the number format "#,##0.00".
//Any changes to cells will also be rounded depending on the number format.
ws.Calculate(); //Calculation results will also be rounded in the sane way.
//Now the values in A1:A3 will be:
Assert.AreEqual(123.46, ws.Cells["A1"].Value);
Assert.AreEqual(987.65, ws.Cells["A2"].Value);
Assert.AreEqual(1111.11D, ws.Cells["A3"].Value);
}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