jasonrogena / jasonrogena/php-excel-reader

Labels incorrects

Open
#51 0 comments 0 reactions 0 assignees View on GitHub
auto-migrated Priority-Medium Type-Defect
Dominant language
PHP
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

```
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:
- [mes prospects.xls](https://storage.googleapis.com/google-code-attachments/php-excel-reader/issue-51/comment-0/mes prospects.xls)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the LABEL record handling around line 1521 and inspect how BIFF8 records are parsed. Reproduce the problem with the attached “mes prospects.xls” file, then verify that LABEL cells are read correctly for BIFF8 without regressing older Excel versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend, data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.