Search code examples
phpexcelphpexcel-1.8.0

unable to write data using phpexcel


$filepath = longdata.xlsx;
@mkdir($filepath, 0777, true);
$objReader = PHPExcel_IOFactory::createReader('Excel2007');
$objPHPExcel = $objReader->load($filepath);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objPHPExcel->setActiveSheetIndex(0)->setCellValue("C4", "12345");

Above is the code I have written in codeigniter. I am trying to write data to a blank xlsx file but unable to do so. When I try to read data I am able to do it which means phpexcel is working fine. Any help is greatly appreciated.


Solution

  • Forgot to add the line

    $objWriter->save($filepath);
    

    Now the code is working fine.