Home > OS >  Large excel file is not generating, getting error: ERR_INVALID_RESPONSE
Large excel file is not generating, getting error: ERR_INVALID_RESPONSE

Time:02-25

Using PHPExcel library in Codeigniter.

Small excel file of about 20k row lines are generating perfectly, while in the case of large (like 43k row lines) file it gets:

This site can’t be reached

The webpage at 
https://exmple.com/ 
might be temporarily down or it may have moved permanently to a new web address.

ERR_INVALID_RESPONSE

I've tried-

ini_set('max_input_vars', 19999);
set_time_limit ( 6000 );
ini_set('max_execution_time',  6000);

memory_get_usage(true);

but didn't get result.

Codeigniter Version: 3.1.11
PHP Version: 7.4

Part of code if needed (its not exact code):

public function test(){
    $this->load->library('Excel');
    ob_start();
    // Create new PHPExcel object
    $objPHPExcel = new PHPExcel();
    $exlHeading = array(
        'font' => array(
            'bold' => true,
            'size' => 12,
            'name' => 'Verdana')
        );
    // Set document properties
    $objPHPExcel->getProperties()->setCreator("BigDream India")
            ->setLastModifiedBy("TEST")
            ->setTitle("REPORT")
            ->setSubject("ATTENDANCE REPORT")
            ->setDescription("Attendance Monthly Report")
            ->setKeywords("ATT_REPORT")
            ->setCategory("Excel Sheet");
    
    for($i=0; $i<=40000; $i  ){
        $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A'.$i, 'Test content is here.');
        $objPHPExcel->setActiveSheetIndex(0)->mergeCells("A$i:I$i");
        $objPHPExcel->getActiveSheet()->getStyle("A$i:I$i")->applyFromArray($exlHeading);
    }
    
    $objPHPExcel->getActiveSheet()->setTitle('Attendance Monthly Report');
    $objPHPExcel->setActiveSheetIndex(0);
    ob_end_clean();
    
    $filename = 'MyOfficeGuardian-Monthly_Report.xls'; 
    header('Content-type: application/vnd.ms-excel');
    header('Content-Disposition: attachment;filename="' . $filename . '"'); 
    header('Cache-Control: max-age=0');
    $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
    $objWriter->save('php://output');
}

CodePudding user response:

Issue resolved by just updating upload_max_filesize value from 2mb to 20mb in php.ini file.

  • Related