From 0b3deeaac5fcc384116a603ebcc248169ff53bd7 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 04a31add..a68d0ab2 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 607d1dda..3464acb6 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 a7584ee4..a70a1ddf 100644 --- a/tests/data/Style/NumberFormat.php +++ b/tests/data/Style/NumberFormat.php @@ -206,4 +206,14 @@ return [ 9.98, '[$-1010409]#,##0.00;-#,##0.00', ], + [ + ' $ 23.06 ', + 23.0597, + '_("$"* #,##0.00_);_("$"* \(#,##0.00\);_("$"* "-"??_);_(@_)', + ], + [ + ' € 13.03 ', + 13.0316, + '_("€"* #,##0.00_);_("€"* \(#,##0.00\);_("€"* "-"??_);_(@_)', + ], ];