Reputation: 1078
How to delete rows of excel sheet generated by phpexcel.
I have tried this
$sheet->getActiveSheet()->removeRow(2,2);
to delete two rows starting from second row. but seems not working...
Upvotes: 1
Views: 4612
Reputation: 125526
you are need to writing the changes back to the file , see example
http://phpexcel.codeplex.com/discussions/80845
error_reporting(E_ALL);
set_time_limit(0);
/** Include path **/
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
/** PHPExcel_IOFactory */
include 'PHPExcel/IOFactory.php';
$fileType = 'Excel5';
$fileName = 'deleteRowTest.xls';
$objPHPExcel = PHPExcel_IOFactory::load($fileName);
$objPHPExcel->getActiveSheet()->removeRow(2,2);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $fileType);
$objWriter->save($fileName);
Upvotes: 1