2019-03-29 14:06
浏览 136


So I try to put data into a Excel sheet, I do it this way,

first is send the data via a ajax post:

  <!doctype html>
  <html lang="en">
  <script src=""></script>
$("#form").on('submit', function() {
    $(function() {
        var hello = "hello world";
        $.ajax ({
            type: 'POST',
            url: 'example.php',
            data: {hello: hello},
            success: function(result) {
   <form id="form" action="example.php" method="post">
   <input type="submit" value="submit">

Then I put it into a excel sheet:

   include "../includes/PHPExcel.php";

   $title = "Verrijking ";

   $hello = $_POST['hello'];

   $objPHPExcel = new PHPExcel();
   $objPHPExcel->getProperties()->setCreator("RM Netherlands B.V.")
        ->setLastModifiedBy("RM Netherlands B.V.")

   $pcbestand = date('Ymdhis') . ".xlsx";

        ->setCellValue("A"."1", $hello);

   $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

   $file = $pcbestand;
   header('Content-disposition: attachment; filename='.$file);
   header('Content-type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
   header('Content-Length: ' . filesize($file));
   header('Content-Transfer-Encoding: binary');
   header('Cache-Control: must-revalidate');
   header('Pragma: public');

  $DelFilePath = $setup['/var/www/clients/client1/web1/web/nordin/'.$pcbestand.''] . $pcbestand;

  if (file_exists($DelFilePath)) { unlink ($DelFilePath); }

the last part create's a save as file dialog and make's sure it isn't uploaded to the server.

But this is the problem I don't get the ajax post ($_POST['hello']) into my excel sheet even tho the ajax post is successful. What am I doing wrong? please help.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题