ricardo
ricardo

Reputation: 1611

PHP - Read cell on PHPExcel as it is on xls file

I have some cell on excel file with General format. The value of this cell is

1,99
10,88

Using phpexcel, When I read the cell i got:

1.99
10.88

How can I get the original value 1,99 ?

I did try

$sheet->getCell("C2")->getValue();
$sheet->getCell("C2")->getFormattedValue()

But both return the

1.99
10.88

Upvotes: 0

Views: 455

Answers (1)

Mark Baker
Mark Baker

Reputation: 212522

PHPExcel cannot possibly know the locale setting that are configured for any users version of MS Excel, and handling of locale-specific formattings (such as decimal commas rather than points) is specific to an instance of MS Excel itself. If I opened that same file in my copy of MS Excel, then I would see a decimal point... i.e. local settings aren't defined in the file, they're purely in the MS Excel GUI.

If you need to format specific to a users locale, then retrieve the raw data using getValue(), and use PHP's Intl NumberFormatter to localise the format.

Upvotes: 2

Related Questions