Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All rows seem empty except for first row (XLSX File) #76

Open
waterball37 opened this issue Jan 6, 2015 · 3 comments
Open

All rows seem empty except for first row (XLSX File) #76

waterball37 opened this issue Jan 6, 2015 · 3 comments

Comments

@waterball37
Copy link

Hey there.

First, thank you for making this platform.

I have a big XLSX (~400k rows) file, and Im trying to parse it.

I followed the instructions and my code looks like this:

require('SpreadsheetReader.php');
$Reader = new SpreadsheetReader('test.xlsx');
$Reader -> ChangeSheet(0);
foreach ($Reader as $Row)
{
var_dump($Row);
}

it only dumps the first row (the header) correctly and all the next rows, are shown as arrays with empty strings.

what do I need to do here?

Thanks;
Haim

@PauliusMacernis
Copy link

Did you (or anybody else) solved the problem? It seems I have the identical one...
My file (xlsx) isn`t so big as yours, but the problem exists anyway. I have couple of files with the same issue appearing. The smallest file is 11 lines long.

The problem disappears if I make a filter in MS Excel (Data > Filter) and save the file like that. Reading the file with the filter makes no problems. However, this is not a solution I would like to accept :)

I guess that you got arrays of empty strings, because the data you try to import is a text data. Am I right? I have data mixed (some cells contains numbers, some texts). It seems that every element of the row (=every value of array) is run throw some kind of numeric conversion.. If the cell contains number then I get the number output, otherwise I get empty.

Update 1
I believe it has something to do with shared strings. In my case,
$this -> SharedStrings -> read()
returns false

I have just compared sharedStrings.xml of both files and I see that the opening sst tag of the file returning empty lines looks like this:
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
..and the tag with filter on looks like this:
<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="812" uniqueCount="163">

So PrepareSharedStringCache method returns false, $this -> SharedStringCount becomes set to NULL.

..after

private function GetSharedString($Index) of class SpreadsheetReader_XLSX
gets into work. At my own case, the $index gets value of 32

then php reaches these lines:

// Finding the unique string count (if not already read) if ($this -> SharedStringIndex == 0 && !$this -> SharedStringCount) { while ($this -> SharedStrings -> read()) { if ($this -> SharedStrings -> name == 'sst') { $this -> SharedStringCount = $this -> SharedStrings -> getAttribute('uniqueCount'); break; } } }

Value of $this -> SharedStringIndex is 0 at that moment.
Value of $this -> SharedStringCount is null at that moment.

..so it goes into if statement

..and finds there $this -> SharedStrings -> read() which returns false.

...at the end the method returns "" (empty string).

@timestee
Copy link

timestee commented Oct 9, 2016

I have the identical one too, only get the first row or the last row, all the other rows disappear...

@kAlvaro
Copy link

kAlvaro commented Jul 19, 2018

Please check #149 for a bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants