无法使用PHPEXCEL1.8

时间:2016-08-21 06:33:44

标签: php phpexcel-1.8.0

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

0 个答案:

没有答案
相关问题