I am working on a complex program that deals with Excel, so I am using PHPExcel to search and edit the Excel file from a browser. My problem comes in the editing portion of the program, so I wrote a basic program to edit the existing Excel page. It seems that PHPExcel does not recognize the file created in Excel as an Excel file. This is done on my own server with an Excel page I created with Excel. The filename is 062014.xlsx. On the HTML side I named the text boxes C3, D3, and E3, so their names will easily correspond with Excel cells ( where the php $cell variable comes from). What I want to do is take the text in the html text boxes and rewrite corresponding cells in Excel with the data from the html textboxes. Posted is my whole code from html and php, if someone can tell me where my program is going wrong, I would greatly appreciate it.
<html>
<head>
<form method="POST" action="lilrevisetest.php" id="excelform">
<input type="text" value="foo" name="C3" />
<input type="text" value="foo" name="D3" />
<input type="text" value="foo" name="E3" />
<button type="submit">Submit</button>
</form>
</body>
</html>
<body>
<html>
<?php
include 'PHPExcel/IOFactory.php';
$n=1;
$x="C";
$y=1;
$file = "062014.xlsx";
$inputFileType = PHPExcel_IOFactory::identify($file);
$inputFileType = 'Excel5';
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
$objReader->setReadDataOnly(false);
$objPHPExcel = $objReader->load($file);
$objWorksheet = $objPHPExcel->getActiveSheet();
$fileObj = fopen("$file", "rt" );
$y = 3;
$x= "C";
for($n=1; $n<4; $n++){
$cell = $x . $y;
echo $cell;
if (isset($_POST[$cell])){
$string = ($_POST[$cell]);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, $inputFileType);
$objWorksheet ->setCellValue("$cell","$string");
$objWriter->save($file);
}
echo "<td> <input type ='text' value= '$string' name = '$cell'/></td>";
$x= ++$x;
}
?>
</html>
</body>