From 4d1ff417c31d7a1d75e20a1ca6f5e4f8da48f2fb Mon Sep 17 00:00:00 2001 From: Harry Gulliford Date: Thu, 30 May 2019 17:18:03 +1000 Subject: [PATCH] Add accounting number format style (#974) --- CHANGELOG.md | 1 + src/PhpSpreadsheet/Style/NumberFormat.php | 2 ++ tests/data/Style/NumberFormat.php | 10 ++++++++++ 3 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 04a31add63..a68d0ab2a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/PhpSpreadsheet/Style/NumberFormat.php b/src/PhpSpreadsheet/Style/NumberFormat.php index 607d1ddabd..3464acb635 100644 --- a/src/PhpSpreadsheet/Style/NumberFormat.php +++ b/src/PhpSpreadsheet/Style/NumberFormat.php @@ -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. diff --git a/tests/data/Style/NumberFormat.php b/tests/data/Style/NumberFormat.php index a7584ee4f3..a70a1ddf57 100644 --- a/tests/data/Style/NumberFormat.php +++ b/tests/data/Style/NumberFormat.php @@ -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\);_("€"* "-"??_);_(@_)', + ], ];