1

I am trying to write data to an excel sheet that is already created and the values entered on the field will be stored on the excel sheet and i am using PHPExcel 1.8 but unable to write to EXCEL sheet. Here is the code : 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 Answers0