简体   繁体   中英

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 !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM