Add support for one digit decimals (FORMAT_NUMBER_0, FORMAT_PERCENTAGE_0) (#2525)

* Add support for one digit decimals (FORMAT_NUMBER_0)

* Add support for one digit decimals (FORMAT_NUMBER_0, FORMAT_PERCENTAGE_0)

* adding tests for one digit numbers

* cleanup

* add failing test to block merge of this PR until #2555 has been merged

* fix code style

* fix test
This commit is contained in:
Sebastian Nohn 2022-02-05 21:46:50 +01:00 committed by GitHub
parent b5c03fc61f
commit 454c01be51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 0 deletions

View File

@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
- Full support of the above CF Rules for the Xlsx Reader and Writer; even when the file being loaded has CF rules listed in the `<extLst><ext><ConditionalFormattings>` element for the worksheet rather than the `<ConditionalFormatting>` element.
- Provision of a CellMatcher to identify if rules are matched for a cell, and which matching style will be applied.
- Improved documentation and examples, covering all supported CF rule types.
- Add support for one digit decimals (FORMAT_NUMBER_0, FORMAT_PERCENTAGE_0)
### Changed

View File

@ -10,11 +10,13 @@ class NumberFormat extends Supervisor
const FORMAT_TEXT = '@';
const FORMAT_NUMBER = '0';
const FORMAT_NUMBER_0 = '0.0';
const FORMAT_NUMBER_00 = '0.00';
const FORMAT_NUMBER_COMMA_SEPARATED1 = '#,##0.00';
const FORMAT_NUMBER_COMMA_SEPARATED2 = '#,##0.00_-';
const FORMAT_PERCENTAGE = '0%';
const FORMAT_PERCENTAGE_0 = '0.0%';
const FORMAT_PERCENTAGE_00 = '0.00%';
const FORMAT_DATE_YYYYMMDD2 = 'yyyy-mm-dd';

View File

@ -591,6 +591,61 @@ return [
'1.9',
NumberFormat::FORMAT_NUMBER,
],
[
'1.0',
'1.000',
NumberFormat::FORMAT_NUMBER_0,
],
[
'-1.0',
'-1.000',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.0',
'1',
NumberFormat::FORMAT_NUMBER_0,
],
[
'-1.0',
'-1',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.0',
'1',
NumberFormat::FORMAT_NUMBER_0,
],
[
'0.0',
'0',
NumberFormat::FORMAT_NUMBER_0,
],
[
'0.0',
'-0',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.1',
'1.11',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.1',
'1.14',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.2',
'1.15',
NumberFormat::FORMAT_NUMBER_0,
],
[
'1.2',
'1.19',
NumberFormat::FORMAT_NUMBER_0,
],
[
'0.00',
'0',
@ -831,6 +886,66 @@ return [
'-0.019',
NumberFormat::FORMAT_PERCENTAGE,
],
[
'0.0%',
'0',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'1.0%',
'0.01',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'1.1%',
'0.011',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'1.1%',
'0.0114',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'1.2%',
'0.0115',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'1.2%',
'0.0119',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'0.0%',
'-0',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'-1.0%',
'-0.01',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'-1.1%',
'-0.011',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'-1.1%',
'-0.0114',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'-1.2%',
'-0.0115',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'-1.2%',
'-0.0119',
NumberFormat::FORMAT_PERCENTAGE_0,
],
[
'0.00%',
'0',