gitspider / php-excel-reader

php-excel-reader
0 stars 0 forks source link

Currency symbol (eg £ or $) causing error #88

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Do a Currency format on number (eg. 10.65 to either £10.65 or $10.65)
2. $data = new Spreadsheet_Excel_Reader("$filename",false);
3. print_r($data);

What is the expected output? 

Array output from;
$data = new Spreadsheet_Excel_Reader("$filename",false);
$rows = $data->rowcount($sheet_index=0);
$cols = $data->colcount($sheet_index=0);
print_r($data); 
...
[6] => $55.43
[7] => $44.95
...

What do you see instead?

Array output from;
$data = new Spreadsheet_Excel_Reader("$filename",false);
$rows = $data->rowcount($sheet_index=0);
$cols = $data->colcount($sheet_index=0);
print_r($data); 
...
[6] => [$$-55]55
[7] => [$$-45]45
...

Please provide any additional information below.

                                    [7] => [$£-67]67

Original issue reported on code.google.com by PDFmarke...@gmail.com on 28 Sep 2010 at 10:44

GoogleCodeExporter commented 8 years ago
I confirm this bug.

Tested on latest sources (v2.21).

You can see example here:
http://uaezapchasti.com/xls/example.php

The script prints last row in this worksheet: 
http://uaezapchasti.com/xls/test.xls
As you can see, instead of $50,89 or simply 50,89 it is printed: $$-51]51

Here is the script source:

<?php

require_once 'reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('cp1251');
$data->read('test.xls');

for ($j = 1; $j <= $data->sheets[0]['numCols']; $j++)
{
  echo "\"".$data->sheets[0]['cells'][145][$j]."\",";
}

?>

Original comment by BEZ...@gmail.com on 30 Nov 2010 at 7:43

GoogleCodeExporter commented 8 years ago
Try this on line 1120:

$retstr = ($asciiEncoding) ? iconv('CP1252', $this->_defaultEncoding, $retstr) 
:                                                        : 
$this->_encodeUTF16($retstr);

Original comment by olivier....@gmail.com on 31 Dec 2010 at 12:56

GoogleCodeExporter commented 8 years ago
I'm still having problems with currency formated cells, even with "the patch on 
line 1120".
12,34€ becomes 12\0\012\012\012\0.\012\012\0\0 \0\0¬ \0 once converted ad 
written in a csv with dump_csv.
Tested on latest sources (v2.21).

Original comment by julien.r...@gmail.com on 2 May 2011 at 9:30

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also, there is no difference in output between Euro and Dollars. I always see 
only $.

Original comment by djonl...@djonline.ru on 27 Feb 2015 at 4:13