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

PHP 5.6: Numbers shown with scientific notation even if explicitly formatted as text #681

Closed
bhargav960143 opened this issue Sep 18, 2018 · 2 comments
Labels

Comments

@bhargav960143
Copy link

bhargav960143 commented Sep 18, 2018

This is:

- [X ] a bug report

What is the expected behavior?

Export value as text

test_5.6.36.xlsx

89898989898958584854

What is the current behavior?

Exported value as number in scientific notion

test_5.6.36.xlsx

8.9869E+18

""

What are the steps to reproduce?

<?php

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

$data = array('number' => '89898989898958584854');
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getSheet(0);
$sheet->fromArray($data, null, 'A1');
$sheet->getStyle('A1')
    ->getNumberFormat()
    ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);

$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$filename = 'test_' . PHP_VERSION . '.xlsx';
$writer->save($filename);
exit;

Which versions of PhpSpreadsheet and PHP are affected?

phpspreadsheet: ^1.4
PHP 5.6.36
Tested on Windows English and Excel 2007 English. (Working)
Tested on Linux 2017 x86_64 (Host: x86_64-redhat-linux-gnu) (Not Working)

  • Linux system is my server hosting system (Already configured system requirements.)

Required Format

required_format

Current Format

current_format

@stale
Copy link

stale bot commented Nov 18, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@stale stale bot added the stale label Nov 18, 2018
@stale stale bot closed this as completed Nov 25, 2018
@kalabro
Copy link

kalabro commented May 23, 2019

As a workaround, I set format to NumberFormat::FORMAT_NUMBER and it is displayed properly (as a number still).

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

No branches or pull requests

2 participants