PhpSpreadsheet icon indicating copy to clipboard operation
PhpSpreadsheet copied to clipboard

Add format number with thousands separator and no decimal

Open reetp opened this issue 7 months ago • 1 comments

Add format number with thousands separator and no decimal "#,##0'"

This is:

  • [X ] a new feature

Why this change is needed?

Because I can't format a number wihtout decimal places.

Fixes Github #4443

reetp avatar Apr 14 '25 09:04 reetp

Please add formal unit test(s) to show that your new constant works correctly.

oleibman avatar Apr 14 '25 14:04 oleibman

3 months, no update, closing.

oleibman avatar Jul 15 '25 06:07 oleibman

I'm not a coder so no idee how to do tests.

Thanks.

reetp avatar Jul 15 '25 07:07 reetp

Wouldn't it be better if you told me that when I asked instead of just ignoring my request?

Feel free to open a new PR if you wish. Your test should actually be pretty easy. Take a look at tests/data/NumberFormat.php. It has entries like:

    [
        ' $ 1,111.11 ',
        '1111.111',
        NumberFormat::FORMAT_ACCOUNTING_USD,
    ],

The second line is the expected result of the formatting, the next line is the value which is to be formatted, and the next line is the format which is to be used. Add an entry to this file using your new constant. Be aware of my comment above that a more descriptive name is needed for the constant.

oleibman avatar Jul 15 '25 07:07 oleibman