Skip to content

PhpOffice\PhpSpreadsheet\Reader\Html::load not working for html files smaller than 2048 bytes. #194

Closed
@victortodoran

Description

This is:

What is the expected behavior?

The bug refers to the PhpOffice\PhpSpreadsheet\Reader\Html::canRead($filename).
To return true if a valid html file(path) is served.

What is the current behavior?

If the filesize is smaller than 2048 the value of the self::TEST_SAMPLE_SIZE the function
will always return false since inside the Html::readEnding() nothing is read by the
fread($this->fileHandle, $blockSize).

I suspect this is caused by the fact that Html::readBegining() is reading after EOF and
fseek($this->fileHandle, $size - $blockSize); does not have the expected behaviour.

Because of this issue I'm unable to load any html file that has a size smaller than 2048.

What are the steps to reproduce?

Please provide a Minimal, Complete, and Verifiable example of code that exhibits the issue without relying on an external Excel file or a web server:

<?php

require __DIR__ . '/vendor/autoload.php';

// add code that show the issue here...

$reader = new Html();
$spreadsheet = $reader->load("test.html"); // where test.html filesize < 2048


### Which versions of PhpSpreadsheet and PHP are affected?
Happend in:
PhpSpreadsheet latest (installed with composer require)
PHP 7.0.20

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions