Skip to content

Reading causes loss of precision without any warning #1324

@Brandyparty

Description

@Brandyparty

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 reader should read the data as it is. All data should be converted correctly without loss of precision.

What is the current behavior?

Numbers are converted losing precision. The number '753,149999999999' for example gets changed to '753.15'.

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...
$spreadsheet = reader->load('yourexcel.xlsx');
$spreadsheet = $this->spreadSheetPreparationForWrite($spreadsheet, 1);
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Csv($spreadsheet);
$writer->setSheetIndex(1);
$writer->save('savedas.csv');
### Which versions of PhpSpreadsheet and PHP are affected?

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