Skip to content

Currency and Accounting format wizards unable to generate formats with ISO code currencies. #4125

@Geries

Description

@Geries

This is:

What is the expected behavior?

Apply a valid currency format.

What is the current behavior?

Excel does not accept the format code, displays issue on open.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$sheet = $spreadsheet->getActiveSheet();
$sheet->getCell([1, 1])->setValue(1234)->getStyle()->applyFromArray(
    [
        'numberFormat' => [
            'formatCode' => (new \PhpOffice\PhpSpreadsheet\Style\NumberFormat\Wizard\Accounting('EUR'))->format(),
        ],
    ]
);

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

.xlsx, most likely others too.

Which versions of PhpSpreadsheet and PHP are affected?

PHP: 8.2
PhpSpreadsheet: at least up from 2.1.0
Excel: 2021/365
output.xlsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions