Reputation: 181
I installed Laravel excel and created a form. I have completed all the configurations related to Laravel excel. I select and upload my excel file in the form I created, and then I get the following error.
PHP Version: 8.1.7
Laravel Version: 9.11
PHP Info
Zip enabled
Zip version 1.19.5
Libzip headers version 1.8.0
Libzip library version 1.9.0
Could not find zip member zip:///Users/dev/Sites/exaan/storage/framework/cache/laravel-excel/laravel-excel-s3kqNFqinyEPG6SJRC6c3HA1qKfCW0Bk.xlsx#_rels/.rels
Upvotes: 2
Views: 13128
Reputation: 1121
Some of reason of error Could not find zip member
if you use Laravel Excel
package (or PHPExcel
) may be that you handle file import inside Laravel Queued Job
, just use Queued reading solution. An example of error similar to this discussed here.
If nothing helps, use alternative package SimpleXLSX or/and SimpleXLS
Upvotes: 1
Reputation: 21
if your xlsx file had be protected by password, You must remove the password first. or it would be report this error too.
Upvotes: 0
Reputation: 31
in my case it showed this error because the existing Excel was empty. As soon you fill a cell its working.
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\IOFactory;
$inputFileType = 'Xlsx';
$inputFileName = '../storage/app/templates/template.xlsx';
/** Create a new Reader of the type defined in $inputFileType **/
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($inputFileType);
/** Load $inputFileName to a Spreadsheet Object **/
$spreadsheet = $reader->load($inputFileName);
$sheet = $spreadsheet->getActiveSheet();
//Edit the cell values
$sheet->setCellValue('A1', 'Hello');
$sheet->setCellValue('B2', 'World!');
$writer = new Xlsx($spreadsheet);
$writer->save('../storage/app/temp/world4.xlsx');
Upvotes: 1
Reputation: 181
I solved the problem by configuring the filename as follows.
public function importPost()
{
Excel::import(new AccountStatementsImport, $request->file('file')->store('temp'));
return back();
}
Upvotes: 4