1

我正在尝试将数据写入已经创建的 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>
4

0 回答 0