Skip to content

Reader reports (non-existent) extra blank rows in Excel sheet #95

Open

Description

@tentwofour

I have a large-ish spreadsheet (3019 rows inc. header row) that the ExcelReader seems to be finding an extra 7 rows in ($reader->count() yields 3026). I'm no Excel expert, but my manual attempts to find any columns with hidden characters, deleting all rows from 3020 -> 10000 and writing a macro to count the rows all seem to say there are only 3019 rows.

It's entirely possible I'm awful with Excel, and just can't see some hidden characters, but even an iteration in my code over rows 3018 -> $reader->count(), all columns are indeed "NULL".

Within my code, I have this, where $file is the attached file 'Master List.xlsx'

$file = new \SplFileObject($file->getPathname());

        try {
            $reader = new ExcelReader($file, 0, 0);

            echo('count:'.$reader->count()); // 3026

            $this->ensureColumnHeadersMatchExpected($reader);
            $this->remapColumnHeadersToEntityMapping($reader);

            // Need to alter the reader, so convert to array; changes to the Reader object aren't persisted in the object memory
            $items = iterator_to_array($reader);

            echo('count:'.$items); // Still 3026, obviously
            
            // As of late 2018, the reader appears to think that the spreadsheet has an extra 7 rows that are blank...
            // This is even after swapping phpexcel for port/excel...wtf.
            $this->removeEmptyRows($items);

            $this->splitAndMapRelations($items);

            $this->sanitize($items);

            // Return a plain 'ol array
            return $items;
        } catch (\PHPExcel_Reader_Exception $e) {
            throw new LibraryItemImporterException($e->getMessage());
        } catch (LibraryItemImporterException $e) {
            throw $e;
        }

Master List.xlsx

I shall await, and prepare to be humbled by the Excel gods....

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions