Skip to content

Memory exhausted while load blank excel which the first column setDataValidation with a column range #797

Closed
@yhdban

Description

@yhdban

I has a blank excel file which the first column setDataValidation with a column range.
then when use phpoffice/phpspreadsheet 1.5.2 to load the file, code as follows.

$phpReader = IOFactory::createReader('Xlsx');
$excel = $phpReader->load('D:\\develop\\test.xlsx');

What is the current behavior?

Apache record error log as follows 
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 64 bytes) in phpoffice\phpspreadsheet\src\PhpSpreadsheet\Cell\Coordinate.php on line 336

Activity

yhdban

yhdban commented on Dec 3, 2018

@yhdban
Author
yhdban

yhdban commented on Dec 11, 2018

@yhdban
Author

I chage the data validation code in \PhpOffice\PhpSpreadsheet\Reader\Xlsx.php as follow:

if ($xmlSheet && $xmlSheet->dataValidations && !$this->readDataOnly) {
	foreach ($xmlSheet->dataValidations->dataValidation as $dataValidation) {
		$docValidation = new DataValidation();
		$docValidation->setType((string) $dataValidation['type']);
		$docValidation->setErrorStyle((string) $dataValidation['errorStyle']);
		$docValidation->setOperator((string) $dataValidation['operator']);
		$docValidation->setAllowBlank($dataValidation['allowBlank'] != 0);
		$docValidation->setShowDropDown($dataValidation['showDropDown'] == 0);
		$docValidation->setShowInputMessage($dataValidation['showInputMessage'] != 0);
		$docValidation->setShowErrorMessage($dataValidation['showErrorMessage'] != 0);
		$docValidation->setErrorTitle((string) $dataValidation['errorTitle']);
		$docValidation->setError((string) $dataValidation['error']);
		$docValidation->setPromptTitle((string) $dataValidation['promptTitle']);
		$docValidation->setPrompt((string) $dataValidation['prompt']);
		$docValidation->setFormula1((string) $dataValidation->formula1);
		$docValidation->setFormula2((string) $dataValidation->formula2);
		$docSheet->setDataValidation(str_replace('$', '', $dataValidation['sqref']), $docValidation);
	}
}
stale

stale commented on Feb 9, 2019

@stale

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.

huelsgp27

huelsgp27 commented on Nov 15, 2024

@huelsgp27

same issue

<dataValidation type="list" allowBlank="1" showInputMessage="1" showErrorMessage="1" sqref="N\$1:N\$1048576"> <formula1>&quot;A, B, C&quot;</formula1> </dataValidation>

oleibman

oleibman commented on Nov 16, 2024

@oleibman
Collaborator

I have some ideas here. It may require a breaking change.

added a commit that references this issue on Nov 24, 2024
1fe51bf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @oleibman@yhdban@huelsgp27

      Issue actions

        Memory exhausted while load blank excel which the first column setDataValidation with a column range · Issue #797 · PHPOffice/PhpSpreadsheet