A pure PHP library for reading and writing spreadsheet files
MIT License
11573
315
2806

This is:

What is the expected behavior?

For the float property to not contain commas but a dot character instead.

What is the current behavior?

The float is formatted using the current PHP locale.

What are the steps to reproduce?

  1. Set the locale to something that doesn't use . as the decimale separator.
  2. Create a custom property of type float.
  3. Write the document to xlsx.

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';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
setlocale(LC_ALL, 'fr_CA');
$spreadsheet->getProperties()->setCustomProperty('my_property_name', 3.01, 'f'); //name,val,type
$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->save('test.xlsx');

Opening the file gives you this:
image

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

I don't know, it affect xlsx...

Which versions of PhpSpreadsheet and PHP are affected?

I just updated to version 1.25.

Where's the problem?

It seems to be that when you use 'f' as the type, it casts the value to a float here:

return (float) $propertyValue;

Then when the document is written it uses an XML writer to write the float here:

case Properties::PROPERTY_TYPE_FLOAT:

The xml writer in PHP spreadsheet extends PHP's built-in writer, and if you look at the parameters here you can see that the writeElement method accepts a string type as a value:
https://www.php.net/manual/en/xmlwriter.writeelement.php

When you cast a float to a string, PHP uses the locale to format it: https://stackoverflow.com/questions/17587581/php-locale-dependent-float-to-string-cast

Excel doesn't like this. So it needs to be converted to a string and formatted manually to use a . character as the decimal separator before calling writeElement.

This is:

- a bug report or a feature request

i need to get values of dropdown list in xlsx file
but with

$test = $validation->getFormula1();
i get only the nameof the dropdown but no values

in this link xlsx image https://i.stack.imgur.com/mJ73K.png
and here Inserimento_Personal Computer (acquisto).xlsx the intrested file

What are the steps to reproduce?

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

// add code that show the issue here...
$inputFileName = 'file.xlsx';
$spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load($inputFileName);
$sheet = $spreadsheet->getSheet(2);

$validation = $sheet->getCell('F3')
->getDataValidation();
$test = $validation->getFormula1();
$test1 = $validation->getFormula2();

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

xlsx files

Which versions of PhpSpreadsheet and PHP are affected?

php 7.4 --- PhpSpreadsheet 1.25.2

This is:

What is the expected behavior?

There should be no change to the files cell except to the formula. In this example case the formula is not actually updated just set again to the same value.
The expected result is :
lica_good

What is the current behavior?

The file is changed and one other cell has it's content replaced by the formula.
This is what the wrong result looks like :
lica_bad

As far as I can tell there is indeed a single setValue call from the processCellFormula function, and the iteration ony find one formula cell.

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("vendor/autoload.php");

function processCellFormula($cell) {
    $formula = $cell->getValue();
    $formula = str_replace('[0]!', '', $formula);
    $cell->setValue($formula);
}

$xlsxReader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
$workbook = $xlsxReader->load('test_lica.xlsx');    

$formulaCells = [];

$doItInForeach = false;


foreach ($workbook->getWorksheetIterator() as $worksheet) {
    foreach ($worksheet->getRowIterator() as $row) {
        $cellIterator = $row->getCellIterator();
        $cellIterator->setIterateOnlyExistingCells(true);
        foreach ($cellIterator as $cell) {
            if ($cell->isFormula()) {                    
                $formulaCells[] = $cell;  
                if ($doItInForeach) {                        
                    processCellFormula($cell);
                }
            }
        }
    }
}

if (!$doItInForeach) {    
    foreach($formulaCells as $formulaCell) {
        processCellFormula($formulaCell);        
    }
}

$writer = new  \PhpOffice\PhpSpreadsheet\Writer\Xlsx($workbook);
$writer->save('lica.xlsx');

The test file is provided as an attachment : test_lica.xlsx

The issue seems to happen only when storing the formulaCells and doing something with them later.
In my real use case (not the test above) I'm doing several things before modifying the formulas if I need, as I've had to browse the cells for a previous step I would like to avoid going through all the cells a second time by keeping them stored for the time I need them.

In this test case if you switch the boolean for $doItInForEach to true the result will be correct, although logically there should not be a difference between both version. In both cases there is only one formula in the example file, and it will modify a non formula cell without reason, if not doing it right when doing the cell iteration.

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Tested and reproduced on XLSX and ODS files.

Which versions of PhpSpreadsheet and PHP are affected?

PhpSpreadsheet version 1.16 and above example is not working on earlier versions.
Tested with PHP 7.3.1, 8.1.0 and 8.1.11

This is:

- [x] a bug report

I have found this line:

if ($this->from->cellAddress() === $this->to->cellAddress()) {

Which effectively convert a range into a single cell, which then causes errors in other functions that explicitely require a range cell name, even of the range consists of just one field.

So the result is, i cannot set AutoFilter with a range of one cell and it will throw an error

Cell get's converted here (__toString is called):

return (string) $cellAddress;

Error thrown here

throw new PhpSpreadsheetException('Autofilter must be set on a range of cells.');

Filter isset with:

public function setAutoFilterByColumnAndRow($columnIndex1, $row1, $columnIndex2, $row2)

The current workaround is to use setAutoFilter instead of setAutoFilterByColumnAndRow and providing a string range.

This is:

- [ ] a bug report
- [x] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

It would be great if PhpSpreadsheet allowed to create Drawings not just from files in the file system, but from streams and/or strings as well.

This would help in cases when the file in question is stored not locally, but on the cloud, or in a filesystem abstraction such as FlySystem. It seems like right now, if an image is stored in FlySystem for example, it has to be downloaded and stored locally to be available for inclusion. It would be great if that step of storing it locally (and cleaning up afterwards) could be skipped.

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

After we save a Numbers XLSX file on MAC and simply loaded and saved the file by the library,
the foreground colors of cells should be same as the original one.

What is the current behavior?

The foreground colors of cells are changed after saved.

What are the steps to reproduce?

  1. Install the latest version of library
    composer require phpoffice/phpspreadsheet:1.25.2

  2. Open a xlsx file by macOS (version 10.15.7) Numbers (version 6.2).

  3. Add foreground colors at some cells

  4. Export to xlsx file formats in Numbers on Mac (File > Export to > Excel). For example, we get excel_file1_mac.xlsx

  5. Simply load and save the xlsx file (see the sample code).
    We get the output xlsx file excel_file1_mac_ouput.xlsx which has different foreground colors.

<?php

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

  $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
  $spreadsheet = $reader->load("excel_file1_mac.xlsx");
  (new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet))
      ->save("excel_file1_mac_output.xlsx");

Possible root cause

The issue may be the xlsx reader loses the indexed color styles after loading spreadsheet.

Unzip the source file excel_file1_mac.xlsx and open the stylesheet. (xl/styles.xml)

<?xml version="1.0" encoding="UTF-8"?>
<styleSheet>
     <!-- ignore -->
    <fills count="7">
        <fill>
            <patternFill patternType="solid">
                <fgColor indexed="11"/>
                <bgColor auto="1"/>
            </patternFill>
        </fill>
        <fill>
            <patternFill patternType="solid">
                <fgColor indexed="12"/>
                <bgColor auto="1"/>
            </patternFill>
        </fill>
        <!-- ignore -->
   </fills>
    <colors>
        <indexedColors>
            <!-- ignore -->
            <rgbColor rgb="ffaaaaaa"/>
            <rgbColor rgb="ffc0c0c0"/>
            <rgbColor rgb="ffffff00"/>
            <rgbColor rgb="ffdfa7a6"/>
            <rgbColor rgb="ff7ba0cd"/>
        </indexedColors>
    </colors>
</styleSheet>

The sample xlsx file has totally 16 indexed colors.

When I see the function extractPalette(), it filters all the indexed colors if there are not exactly 64 indexed colors.

PhpOffice\PhpSpreadsheet\Reader\Xlsx::extractPalette()

    private static function extractPalette(?SimpleXMLElement $sxml): array
    {
        $array = [];
        if ($sxml && $sxml->colors->indexedColors) {
            foreach ($sxml->colors->indexedColors->rgbColor as $node) {
                if ($node !== null) {
                    $attr = $node->attributes();
                    if (isset($attr['rgb'])) {
                        $array[] = (string) $attr['rgb'];
                    }
                }
            }
        }
        return (count($array) === 64) ? $array : [];
    }

Because there is not indexedColors palette, but still has some cells refer to the indexed color. The program use default palette PhpOffice\PhpSpreadsheet\Style\Color::INDEXED_COLORS to render the spreadsheet. Therefore the output xlsx file has wrong colors.

I think that replace the line

return (count($array) === 64) ? $array : [];

with

return $array;

can fix the problem.

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

The issue affects all the border, font, cell foreground colors of the xlsx spreadsheet which is exported by Numbers.

Which versions of PhpSpreadsheet and PHP are affected?

php: 7.4.30
phpoffice/phpspreadsheet: 1.25.2

This is:

- [ ] a bug report
- [x] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

If a formula is invalid, the behaviour is controlled by Calculation::raiseFormulaError that either throws an exception or triggers an error

This is controlled by the suppressFormulaErrors public variable, but there is no easy way to configure that variable at the spreadsheet level. More over, having a public variable is a bit strange (why not a config option on the spreadsheet with proper getters/setters?). Also the doc blocks of raiseFormulaError are not in line with regular docblocks

// trigger an error, but nicely, if need be
protected function raiseFormulaError($errorMessage)

It would be nice to actually allow suppressing errors to allow excel generation and not block the process because of one error in a formula (currently, both errors and exception will block the generation of the file)

As an added bonus, it would be nice if the error message could include the actual formula, in large excel file in can be a real mess to find back which formula is causing the error and why it's invalid. having the cell reference is nice, but the actual formula would be super helpful in my opinion.

What is the current behavior?

If a formula contains an error, it will trigger an error. I don't see how to throw an exception, although it wouldn't suppress anything (contrary to what the variable name would let me believe)

If you want to skip errors, you have to comment out everything in the raiseFormulaError method

// trigger an error, but nicely, if need be
protected function raiseFormulaError($errorMessage)
{
    $this->formulaError = $errorMessage;
    $this->cyclicReferenceStack->clear();
    // if (!$this->suppressFormulaErrors) {
        // throw new Exception($errorMessage);
    // }
    // trigger_error($errorMessage, E_USER_ERROR);

    return false;
}

What are the steps to reproduce?

Just make any sheet with a formula error in it, it will show a Formula Error

<?php

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

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $spreadsheet->getActiveSheet();
// add code that show the issue here...
$sheet->setCellValueByColumnAndRow(1, 1, '=SOMEERRORFUNCTION(A1:A10)');

$writer = IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');

Which versions of PhpSpreadsheet and PHP are affected?

1.8.2 to 1.13

This is:

- [x] a bug report

What is the expected behavior?

File: vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Html.php; function generateStyles()
function generateStyles return CSS in one line ( remove join PHP_EOL );

What is the current behavior?

File: vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Writer\Pdf\Mpdf.php; function save()
generate HTML with CSS in many line.
array_chunk html 1000 line
write each array lines to HTML
=> Error when css > 1000 line; lines[0] have tag "< style >" and lines[1] have close tag "< /style >"

What features do you think are causing the issue

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

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

$reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
$spreadsheet = $reader->load($origin_file);

$writer = new \PhpOffice\PhpSpreadsheet\Writer\Xlsx($spreadsheet);
$writer->setPreCalculateFormulas(false);
$writer->setOffice2003Compatibility(true);
$new_file = './file_uploads/report_file/' . $file_info_idx.'_tmp.'.$file_ext;
$writer->save($new_file);
  • original file

image

  • write new file

image

As above, if you save a picture or image of a specific sheet in the original file as a new file, the picture or image will be lost.
ex) sheet2

Is there something I'm missing out on?

This is:

- [x ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

To convert a specific sheet from an xls file to csv

What is the current behavior?

Throws an error

What are the steps to reproduce?

I have the following function

    public static function convert_xls_to_csv($xls_file_path, $sheet_name, $csv_file)
    {
        $reader = new \PhpOffice\PhpSpreadsheet\Reader\Xlsx();
        $reader->setLoadSheetsOnly([$sheet_name]);
        $spreadsheet = $reader->load($xls_file_path);

        $writer = new PhpSpreadsheet\Writer\Csv($spreadsheet);
        $writer->save($csv_file);
    }

and an 8MB .xls file with 10+ sheets. However Allowed memory size of xxx bytes exhausted error is thrown, e.g.:

Allowed memory size of 576716800 bytes exhausted (tried to allocate 4096 bytes) in ....../vendor/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Reader/Xlsx.php on line 104

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?

1.24.1

This is:

- [ ] a bug report
- [V] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Open the excel file (.xlsx) with dynamic tables and save the same file with dynamic tables

What is the current behavior?

The spreadsheet opens the excel file and saves the file without dynamic tables. Only plain text.

What are the steps to reproduce?

Use reader fuction to open the file
Force to readonly
Define a worksheet
Use writer function to save the file

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';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Spreadsheet;

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

$inputFileName = 'template-sample.xlsx';

$inputFileType = IOFactory::identify($inputFileName);
$reader = IOFactory::createReader($inputFileType);
$reader->setReadDataOnly(true);
$spreadsheet = $reader->load($inputFileName);

$spreadsheet->setActiveSheetIndex(1);

$writer = IOFactory::createWriter($spreadsheet, "Xlsx");
$writer->save("template-test.xlsx");

Which versions of PhpSpreadsheet and PHP are affected?

1.18.0

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

install via composer

What is the current behavior?

i'm using laravel 9 which comes with psr/simple-cache v3

Problem 1
- Root composer.json requires phpoffice/phpspreadsheet ^1.23 -> satisfiable by phpoffice/phpspreadsheet[1.23.0].
- phpoffice/phpspreadsheet 1.23.0 requires psr/simple-cache ^1.0 || ^2.0 -> found psr/simple-cache[1.0.0, 1.0.1, 2.0.0, 2.x-dev] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

i've seen this issue psr/simple-cache:3.0.0 #2703
but unfortunately i need it to be used on the current project i'm working on.

What are the steps to reproduce?

support psr/simple-cache version 3.0

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:

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

PHP8.0 and PhpSpreadsheet 1.23

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

  • Not appear ErrorException

What is the current behavior?

  • I received an ErrorException, but I don't know which cell it is from from the excel template file
    image

What are the steps to reproduce?

I would like to create PR fix as below:

....
$node->addAttribute('sqref', $item->children('xm', true)->sqref ?? null);
$node->addChild('formula1', $item->formula1->children('xm', true)->f ?? null);
....

I'm worried, will this affect performance?

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:

...src\PhpSpreadsheet\Reader\Xlsx.php
....
    /**
     * Loads Spreadsheet from file.
     */
    public function load(string $filename, int $flags = 0): Spreadsheet
    {
       ...
        $node->addAttribute('sqref', $item->children('xm', true)->sqref);
        $node->addChild('formula1', $item->formula1->children('xm', true)->f);
      ...
    }

https://github.com/PHPOffice/PhpSpreadsheet/blob/master/src/PhpSpreadsheet/Reader/Xlsx.php#L901-L902

Which versions of PhpSpreadsheet and PHP are affected?

I have an export of a view in laravel in which I have a table with an SVG image and it gives an error: Failed to load as a DOM Document

This is:

- [X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

This regression is due to a3921d2. The caret version range ^ is missing (https://getcomposer.org/doc/articles/versions.md#caret-version-range-).

What is the expected behavior?

The ezyang/htmlpurifier (v4.16) composer dependency should be installable.

What is the current behavior?

The ezyang/htmlpurifier (v4.16) composer dependency is not installable.

What are the steps to reproduce?

composer.json:

{
	"require": {
		"ezyang/htmlpurifier": "^4.16.0",
		"phpoffice/phpspreadsheet": "^1.25.0"
	}
}

Error occured when running the composer install command:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires phpoffice/phpspreadsheet ^1.25.0 -> satisfiable by phpoffice/phpspreadsheet[1.25.0].
    - phpoffice/phpspreadsheet 1.25.0 requires ezyang/htmlpurifier 4.15 -> found ezyang/htmlpurifier[v4.15.0] but it conflicts with your root composer.json require (^4.16.0).

Which versions of PhpSpreadsheet and PHP are affected?

v1.25.0

This is:
Fatal error: Constructor PhpOffice\PhpSpreadsheet\Reader\Xlsx\Styles::__construct() cannot declare a return type in D:\xampp\htdocs\dlogger\vendor\phpoffice\phpspreadsheet\src\PhpSpreadsheet\Reader\Xlsx\Styles.php on line 18

- [ X] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

What is the current behavior?

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';

// Create new Spreadsheet object
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();

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

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the current behavior?

PHP Fatal error:  Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed in /var/www/html/vendor/maatwebsite/excel/src/Cache/MemoryCache.php on line 62

   Symfony\Component\ErrorHandler\Error\FatalError 

  Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed

  at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:62
     58▕ 
     59▕     /**
     60▕      * {@inheritdoc}
     61▕      */
  ➜  62▕     public function get($key, $default = null)
     63▕     {
     64▕         if ($this->has($key)) {
     65▕             return $this->cache[$key];
     66▕         }


   Whoops\Exception\ErrorException 

  Declaration of Maatwebsite\Excel\Cache\MemoryCache::get($key, $default = null) must be compatible with Psr\SimpleCache\CacheInterface::get(string $key, mixed $default = null): mixed

  at vendor/maatwebsite/excel/src/Cache/MemoryCache.php:62
     58▕ 
     59▕     /**
     60▕      * {@inheritdoc}
     61▕      */
  ➜  62▕     public function get($key, $default = null)
     63▕     {
     64▕         if ($this->has($key)) {
     65▕             return $this->cache[$key];
     66▕         }

What are the steps to reproduce?

Just update to latest version.

Which versions of PhpSpreadsheet and PHP are affected?

1.25.0

This is:

- [+ ] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

When inserting n rows, the cells with the contents (including formulas and styles) should move correctly n rows below

What is the current behavior?

When inserting n rows of the cell with the contents of the "DropDownList formula" remains on the same row. Also, when trying to install dropDownCell on any row below the inserted cells, the insertion occurs on the incorrect row

What are the steps to reproduce?

Execute the attached code

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';

use PhpOffice\PhpSpreadsheet\IOFactory;

$xlsx = IOFactory::load('Template.xlsx');
$xlsx->setActiveSheetIndex(0);
$sheet = $xlsx->getActiveSheet();

$sheet->insertNewRowBefore(5, 2);

$validation = $sheet->getCell('A8')->getDataValidation();
$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST);
$validation->setFormula1('F1:F3');

$writer = IOFactory::createWriter($xlsx, 'Xlsx');
$writer->save('Result.xlsx');

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

  • Reader
  • Writer
  • Styles
  • Data Validations
  • Form Elements

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Xlsx - affected, xls works fine

Which versions of PhpSpreadsheet and PHP are affected?

checked for php81 & php80, spreadsheet 1.24.1 (can confirm this bug at least from version 1.20, on version 1.18 bug doesn't manifest)
Result.xlsx
Template.xlsx

This is:

- [x] a bug report
- [ ] a feature request
- [ ] **not** a usage question (ask them on https://stackoverflow.com/questions/tagged/phpspreadsheet or https://gitter.im/PHPOffice/PhpSpreadsheet)

What is the expected behavior?

Install on laravel 9

What is the current behavior?

installation error

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:

composer require phpoffice/phpspreadsheet
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires phpoffice/phpspreadsheet ^1.24 -> satisfiable by phpoffice/phpspreadsheet[1.24.0, 1.24.1].
    - phpoffice/phpspreadsheet[1.24.0, ..., 1.24.1] require psr/simple-cache ^1.0 || ^2.0 -> found psr/simple-cache[1.0.0, 1.0.1, 2.0.0, 2.x-dev] but the package is fixed to 3.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g. "composer require phpoffice/phpspreadsheet:*" to figure out if any version is installable, or "composer require phpoffice/phpspreadsheet:^2.1" if you know which you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

If this is an issue with reading a specific spreadsheet file, then it may be appropriate to provide a sample file that demonstrates the problem; but please keep it as small as possible, and sanitize any confidential information before uploading.

What features do you think are causing the issue

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

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Which versions of PhpSpreadsheet and PHP are affected?

php: 8.1.x
phpspreadsheet: latest version

In all of the DefinedNames example files, inserting a column before column B causes the code to explode.
For example in DefinedNames/AbsoluteNamedRange.php
insert a column between column A and B at the end of the spreadsheet generation fails and the NamedRange get out of control.

.....
->setCellValue("B{$row}", $hours)
->setCellValue("C{$row}", "=B{$row}*CHARGE_RATE");
++$row;
}
$endRow = $row - 1;

++$row;
$worksheet
->setCellValue("B{$row}", "=SUM(B{$startRow}:B{$endRow})")
->setCellValue("C{$row}", "=SUM(C{$startRow}:C{$endRow})");

$worksheet->insertNewColumnBefore('B'); <------------------------ line inserted
.....

the code explodes with error in cell coordinate.