Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate excel file containing multiple sheets using PhpExcel

Tags:

phpexcel

I am trying to generate Excel file with multiple worksheets in it, and the file is generating with proper data, but giving error while opening it.

error is as: enter image description here

Also, when I am trying to iterate over sheets through loop, I unable to access sheets except sheet one.

PHP error occured: You tried to set a sheet active by the out of bounds index: 1. The actual number of sheets is 1.

Does that means the others sheets are not inserted while creating file.

like image 640
Arjun Avatar asked Oct 30 '22 23:10

Arjun


1 Answers

use ob_clean() before, php://output as (CORRECT):

ob_clean();
$objWriter->save('php://output');

You may using like (WRONG):

  $objWriter->save('php://output');
ob_clean();
like image 171
VBMali Avatar answered Dec 26 '22 15:12

VBMali