Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scientific Format Mask ignores decimal setting #3381

Closed
1 of 8 tasks
MarkBaker opened this issue Feb 20, 2023 · 0 comments
Closed
1 of 8 tasks

Scientific Format Mask ignores decimal setting #3381

MarkBaker opened this issue Feb 20, 2023 · 0 comments

Comments

@MarkBaker
Copy link
Member

This is:

- [X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

A Scientific Number Format Mask such as '0.000E+00' will render the required number of decimal places. (in this case, 3dp)

What is the current behavior?

The Scientific Number Format Mask only renders 2 decimal places

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();
$worksheet = $spreadsheet->getActiveSheet();

$worksheet->getCell('A1')->setValue(-12345.67890);
$worksheet->getCell('A1')
    ->getStyle()->getNumberFormat()
    ->setFormatCode('0.000E+00');

// Expected result: -1.235E+4
// Actual result: -1.24E+4
var_dump($worksheet->getCell('A1')->getFormattedValue());

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?

Yes

Which versions of PhpSpreadsheet and PHP are affected?

All

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant