Luca Black Luca Black - 9 months ago 73
PHP Question

PHP Excel Reader & Currency

I'm using php excel reader for upload data to db from xls files.

I have a field with a currency ( € 245,78 ) and I can't read with my tool.

If I use this code:

$get_data_ab = utf8_encode($data->val(4,6,$sheet_def));

the result is:

¬ 246246246246.246246

If I use:

$get_data_ab = $data->val(4,6,$sheet_def);

the result is empty.

What is wrong? How can I charge the € values in a variable?


After many researches i found the fix method, i paste it here for who encounter the same problem.

The first thing to do is "add" a true value to the definition of the file:

$data = new Spreadsheet_Excel_Reader($nome_file,true);

After for read a custom number as € 245,78 you have to use this

$get_data_ab = number_format($data->raw(4, 6, $sheet_def), 2);

Hope it helps someone !