jasonrogena / jasonrogena/php-excel-reader

Last character of strings getting cut off [resolved?]

Open
#115 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

```
I had a very strange issue. I'm parsing a spreadsheet to import into mysql. I
have no control over the format or creation of the spreadsheet, it is being
generated by a web application. Digging through excel_reader2.php, it looks
like the problem was occurring in the _parsesheet() function when the $code var
matched case "SPREADSHEET_EXCEL_READER_TYPE_LABEL". The existing code was this:

$this->addcell($row, $column, substr($data, $spos + 8, ord($data[$spos + 6]) |
ord($data[$spos + 7])<<8));

I was able to get the missing character to show up by changing it to this:

$this->addcell($row, $column, substr($data, $spos + 8, ord($data[$spos + 6]) +
1));

Honestly I don't understand the details of what these lines are doing, and I'm
curious if anyone can tell me what was going on. I suspect that these cells
are improperly formatted in the spreadsheet I am receiving. Curiously, if I
open the spreadsheet in excel and resave it, everything works fine without any
modification to the library.
```

Original issue reported on code.google.com by `wright.a...@gmail.com` on 22 Apr 2011 at 4:57

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in excel_reader2.php, in _parsesheet() at the SPREADSHEET_EXCEL_READER_TYPE_LABEL case, and inspect how the label length is decoded before substr() is called. Reproduce the truncation with the affected spreadsheet if available, compare it with a resaved copy, and consider the issue done when label text is read completely without breaking existing spreadsheet parsing.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.