Using PHPExcel to append to an Excel file

时间:2015-05-24 21:58:26

标签: php excel

I want to use a form to add input to an excel file. I have the following HTML form.

    <form action="test_003.php" method="post">
    First Name: <input type="text" name="firstName"><br /><br />
    Last Name: <input type="text" name="lastName"><br /><br />
    E-mail: <input type="text" name="email"><br /><br />
    <input type="submit">
    </form>

and my php is:

    <?php

        /** Include PHPExcel */
        require_once 'Classes/PHPExcel.php';
        require_once 'Classes/PHPExcel/IOFactory.php';

        $objPHPExcel = PHPExcel_IOFactory::load("spread.xlsx");
        $objPHPExcel->setActiveSheetIndex(0);
        $row = $objPHPExcel->getActiveSheet()->getHighestRow()+1;

        $objPHPExcel->getActiveSheet()->SetCellValue('A'.$row, $_POST['firstName']);
        $objPHPExcel->getActiveSheet()->SetCellValue('B'.$row, $_POST['lastName'] );
        $objPHPExcel->getActiveSheet()->SetCellValue('C'.$row, $_POST['email']);

        $objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
        $objWriter->save('spread.xlsx');

    ?>

The problem is that nothing seems to be happening to the spread.xlsx file on the server

0 个答案:

没有答案