Skip to content

Commit

Permalink
Add accounting number format style (PHPOffice#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
harrygulliford authored and guillaume-ro-fr committed Jun 12, 2019
1 parent 1bbfe96 commit 4d1ff41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Added support for inline styles in Html reader (borders, alignment, width, height)
- QuotedText cells no longer treated as formulae if the content begins with a `=`
- Clean handling for DDE in formulae
- Add accounting number format style

### Fixed

Expand Down
2 changes: 2 additions & 0 deletions src/PhpSpreadsheet/Style/NumberFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ class NumberFormat extends Supervisor
const FORMAT_CURRENCY_USD = '$#,##0_-';
const FORMAT_CURRENCY_EUR_SIMPLE = '#,##0.00_-"€"';
const FORMAT_CURRENCY_EUR = '#,##0_-"€"';
const FORMAT_ACCOUNTING_USD = '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)';
const FORMAT_ACCOUNTING_EUR = '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)';

/**
* Excel built-in number formats.
Expand Down
10 changes: 10 additions & 0 deletions tests/data/Style/NumberFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,14 @@
9.98,
'[$-1010409]#,##0.00;-#,##0.00',
],
[
' $ 23.06 ',
23.0597,
'_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)',
],
[
' € 13.03 ',
13.0316,
'_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)',
],
];

0 comments on commit 4d1ff41

Please sign in to comment.