2014-03-03 39 views
0

如何刪除由phpexcel生成的excel表格行。刪除行不在phpexcel中

我已經試過這

$sheet->getActiveSheet()->removeRow(2,2);

刪除兩行從第二行開始。但似乎不工作...

+1

你能爲'$ sheet'添加代碼? –

回答

1

你需要寫更改回文件,見例如

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);