Skip to content

Problems with third-party spreadsheets with namespaces and absolute paths #3138

Closed
@JKoblitz

Description

@JKoblitz

This is:

- [x] a bug report
- [ ] a feature request
- [x] **not** a usage question 

What is the expected behavior?

PhpSpreadsheet should also handle third party spreadsheets.

What is the current behavior?

The spreadsheet is read incorrectly. It is not possible, e.g. to get access to drawings.

What are the steps to reproduce?

Save the following excel file that contains tabular data and one image of a chromatogram:

2022-09-05 15-02-45+02-00-02_1.xlsx

Then open with PhpSpreadsheet:

<?php
// prepare and open file
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$reader->setReadDataOnly(FALSE); // read images and styles as well
$spreadsheet = $reader->load('2022-09-05 15-02-45+02-00-02_1.xlsx');
$worksheet = $spreadsheet->getActiveSheet();

// dumping the drawing collection is empty
var_dump($worksheet->getDrawingCollection()); 

The issue is solven when opening the Spreadsheet with Excel, saving it (without any changes) and trying again.
I had a look at the content of both (the original and the Excel-modified) and found that Excel is removing all namespaces in sheet.xml. There also seem to be problems with absolute file pathes in _rels.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Formula Calculations
  • Charts
  • AutoFilter
  • Form Elements

Which versions of PhpSpreadsheet and PHP are affected?

PHP 7.3.12 and 8.1, PhpSpreadsheet 1.25.2

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