-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresults.php
More file actions
39 lines (33 loc) · 1.22 KB
/
results.php
File metadata and controls
39 lines (33 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require 'vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
function produce_xls($data) { /*{{{*/
$spreadsheet = new Spreadsheet();
$spreadsheet->getActiveSheet()->fromArray(
$data, // The data to set
NULL, // Array values with this value will not be set
'A1' // Top left coordinate of the worksheet range where
);
// Redirect output to a client’s web browser (Xlsx)
header("Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
header("Content-Disposition: attachment;filename=karramba.xlsx");
header("Cache-Control: max-age=0");
header("Cache-Control: max-age=1");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: cache, must-revalidate"); // HTTP/1.1
header("Pragma: public"); // HTTP/1.0
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xlsx');
$writer->save('php://output');
exit;
}
$arrayData = [
['work', 'in', 'progress'],
['work', 'in', 'progress'],
['work', 'in', 'progress'],
['work', 'in', 'progress'],
];
/*}}}*/
produce_xls($arrayData);
?>