ivan-berezhnov / php-excel-reader

Automatically exported from code.google.com/p/php-excel-reader
0 stars 0 forks source link

Labels incorrects #51

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
SPREADSHEET_EXCEL_READER_TYPE_LABEL in excel file version
SPREADSHEET_EXCEL_READER_BIFF8 are not readed correctly.

In BIFF8 a encoding byte was added for LABEL.
row (2 bytes) + col (2 bytes) + string length (2 bytes) + encoding (1 byte).
Encoding byte is equal to 0 (CP1252) or 1 (UTF16).

------------------------
Old code (in line 1521):
------------------------

case SPREADSHEET_EXCEL_READER_TYPE_LABEL:
                    $row    = ord($data[$spos]) | ord($data[$spos+1])<<8;
                    $column = ord($data[$spos+2]) | ord($data[$spos+3])<<8;
                    $this->addcell($row, $column, substr($data, $spos + 8, ord($data[$spos
+ 6]) | ord($data[$spos + 7])<<8));
                    break;

-------------
Replace code:
-------------

case SPREADSHEET_EXCEL_READER_TYPE_LABEL:
                    $row    = ord($data[$spos]) | ord($data[$spos+1])<<8;
                    $column = ord($data[$spos+2]) | ord($data[$spos+3])<<8;
                    $strlen = ord($data[$spos + 6]) | ord($data[$spos + 7])<<8;
                    if ($version == SPREADSHEET_EXCEL_READER_BIFF8) {
                        $encoding = ord($data[$spos + 8]);
                        if ($encoding) {
                            $string = $this->_encodeUTF16($string);
                        }
                        $string = substr($data, $spos + 9, $strlen);
                        $this->addcell($row, $column, $string);
                    }
                    else {
                        $string = substr($data, $spos + 8, $strlen);
                        $this->addcell($row, $column, $string);
                    }
                    break;

Thanks,

José

Original issue reported on code.google.com by jose.des...@acces-industrie.com on 3 Nov 2009 at 11:31

Attachments: