Skip to content

Commit 606f995

Browse files
committed
Document OpenXmlCellValue in README_V2
1 parent 298fba5 commit 606f995

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎README_V2.md‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,28 @@ exporter.Export("Book1.xlsx", dt, configuration: config);
771771

772772
![image](docs/images/freeze-pane-1.png)
773773

774+
#### 14. Per-cell formulas and formatting
775+
776+
Wrapping a value in `OpenXmlCellValue` sets a formula, number format or style for that one cell, overriding the column's settings:
777+
778+
```csharp
779+
var rows = new[]
780+
{
781+
new Dictionary<string, object?>
782+
{
783+
["Input"] = 3,
784+
["Share"] = new OpenXmlCellValue(0.25) { NumberFormat = "0.0%", Style = { FontColor = Color.Red } },
785+
["Double"] = new OpenXmlCellValue(6) { Formula = "A2*2" }
786+
}
787+
};
788+
789+
var exporter = MiniExcelV2.Exporters.GetOpenXmlExporter();
790+
exporter.Export("Book1.xlsx", rows);
791+
```
792+
793+
The value given with a formula is written as its cached result, which Excel shows until it recalculates. Pass `null` to leave the result for Excel to calculate.
794+
A cell with only a style keeps the number format it would otherwise have had.
795+
774796

775797
### Fill Data To Excel Template <a name="docs-template" />
776798

0 commit comments

Comments
 (0)