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

Wont load XLS files with XML content #522

Closed
kaoz70 opened this issue May 30, 2018 · 2 comments
Closed

Wont load XLS files with XML content #522

kaoz70 opened this issue May 30, 2018 · 2 comments

Comments

@kaoz70
Copy link

kaoz70 commented May 30, 2018

This is:

- [X ] a bug report
- [ ] a feature request

What is the expected behavior?

Load XLS files created outside of Excel: We have some XLS files that are created by Facebook's LeadGen forms, they have the extension .xls, but their content is XML.

What is the current behavior?

When I load the file through:

IOFactory::load(Storage::path($path))

PhpSpreadsheet throws the exception:

 DOMDocument::loadHTML(): Tag workbook invalid in Entity, line: 5

The reason it does this is because in the method \PhpOffice\PhpSpreadsheet\Reader\Xml::canRead() there is a signature variable:

$signature = [
        '<?xml version="1.0"',
        '<?mso-application progid="Excel.Sheet"?>',
    ];

Which tries to find it in the first bytes of the file, but in the case of these files they don't have the string:

<?mso-application progid="Excel.Sheet"?>

So it returns false and loads the Html reader.

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:

Sorry, I have to rely on an external file to be able to reproduce this issue:

test.zip

<?php

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

$path = 'test.xls';
 IOFactory::load($path);

If I remove the line in the method: \PhpOffice\PhpSpreadsheet\Reader\Xml::canRead()

$signature = [
        '<?xml version="1.0"',
    ];

It loads as an XML file correctly.

Which versions of PhpSpreadsheet and PHP are affected?

1.2.1

@stale
Copy link

stale bot commented Jul 29, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@oleibman
Copy link
Collaborator

Fixed by PR #1917 in March 2021.

@oleibman oleibman removed the stale label Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants