From 9fff58f6e2a76b5ac366dd903136a67aa4d3c3eb Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 25 Oct 2017 16:08:41 -0400 Subject: [PATCH] Revert "refactor method call" This reverts commit 6a07336f0f584b8195f1a1c48a8222413b2082f0. --- export.php | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/export.php b/export.php index cef679d..6ba6242 100644 --- a/export.php +++ b/export.php @@ -7,25 +7,13 @@ if (empty($_POST["test_cases"])) { die(); } -// split input by line +// split input by line and place into template at cell B2 $cases = explode("\n", $_POST["test_cases"]); +$excel = PHPExcel_IOFactory::load("template.xlsx"); +$excel->getActiveSheet()->fromArray(array_chunk($cases, 1), NULL, 'B2'); // set the right download headers header('Content-Type: application/vnd.ms-excel'); header('Content-Disposition: attachment;filename="testcase-template.xls"'); header('Cache-Control: max-age=0'); - -PHPExcel_IOFactory::createWriter( - PHPExcel_IOFactory::load("template.xlsx") - ->getActiveSheet() - ->fromArray( - // place vertically - array_chunk($cases, 1) - // skip NULLs - , NULL - // starting at B2 - , 'B2' - ) - , 'Excel5' -// save to request page -)->save('php://output'); +PHPExcel_IOFactory::createWriter($excel, 'Excel5')->save('php://output');