我正在尝试将数据写入已创建的Excel工作表,并且在该字段上输入的值将存储在Excel工作表中,我使用的是PHPExcel 1.8但无法写入EXCEL工作表。 这是代码: 的的index.php
<?php
if(isset($_POST['subscribe'])){
require_once 'PHPExcel.php';
require_once 'PHPExcel/IOFactory.php';
try {
header('Content-Type: application/vnd.openxmlformatsofficedocument.spreadsheetml.sheet');
header('Cache-Control: max-age=0');
$objPHPExcel = PHPExcel_IOFactory:: load("oursubscribers.xlsx");
$activeSheet = $objPHPExcel->getActiveSheet();
$activeSheet->setTitle('Subscribers');
$row = $activesheet->getHighestRow()+1;
$row->SetCellValue('A1', $_POST['subscribe']);
echo $row;
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save('php://output');
exit;
}
catch (Exception $e) {
$error = $e->getMessage();
}
}
?>
<form method="POST">
<input type="email" class="form-control" name="subscribe" id="subscribe" placeholder="Your E-mail Address" required >
</div>
<button type="sumbit" class="btn-black"> Subscribe
</button>
</form>