Answer the question
In order to leave comments, you need to log in
Why is Yii2-excel using so much memory with xlsx files?
Uploading a file in xlsx format
$file = UploadedFile::getInstance($this, 'file');
$data = Excel::import($file->tempName);
The file weighs 1 mb the script runs for a very long time sometimes it gives an error about lack of memory I
upload in xls format everything works OK, why is it so, although the data in the files is the same
Answer the question
In order to leave comments, you need to log in
1. Refuse when working with Excel data in the form of objects - pass simple arrays. This will greatly reduce memory, especially if you are using AR.
2. Use queues and a console application. The console application has no memory or duration limits.
xlsx is a zip archive with a bunch of stuff. The fact that the file is 1mb means literally nothing. To parse this file into components, you need quite a lot of memory. PHPOffice / PhpSpreadsheet is used internally, each cell of your document is an object, so count it))
If everything is critical for you from memory, you can look in the direction of converting xlsx -> csv (here we process everything you need) -> xlsx
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question