在现有Excel文件中添加新行而不保存数据

时间:2017-05-19 07:10:20

标签: php excel phpexcel

我试图在现有的xlsx文件中保存新行,但没有发生任何事情,它没有保存任何内容。以下是我的代码:

require_once 'Classes/PHPExcel/IOFactory.php';
require_once 'Classes/PHPExcel/Writer/Excel2007.php';

$objPHPExcel = PHPExcel_IOFactory::load("report.xlsx");
$objPHPExcel->setActiveSheetIndex(0);
$row = $objPHPExcel->getActiveSheet()->getHighestRow()+1;

$objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $_POST['anonymous']);
$objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $_POST['pdoStaff']);
$objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $_POST['mu_number']);
$objPHPExcel->getActiveSheet()->SetCellValue('D'.$row, $_POST['full_name']);
$objPHPExcel->getActiveSheet()->SetCellValue('E'.$row, $_POST['nationality']);
$objPHPExcel->getActiveSheet()->SetCellValue('F'.$row, $_POST['email']);

$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
$objWriter->save('report.xlsx');

0 个答案:

没有答案