2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
2020-05-24 11:03:07 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\Xlsx as XlsxReader;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx as XlsxWriter;
|
2016-08-31 17:18:12 +00:00
|
|
|
|
2017-10-01 08:48:59 +00:00
|
|
|
require __DIR__ . '/../Header.php';
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
// Create temporary file that will be read
|
2017-10-01 08:48:59 +00:00
|
|
|
$sampleSpreadsheet = require __DIR__ . '/../templates/chartSpreadsheet.php';
|
2016-08-31 16:15:54 +00:00
|
|
|
$filename = $helper->getTemporaryFilename();
|
2020-05-24 11:03:07 +00:00
|
|
|
$writer = new XlsxWriter($sampleSpreadsheet);
|
|
|
|
$writer->setIncludeCharts(true);
|
2016-08-31 16:15:54 +00:00
|
|
|
$writer->save($filename);
|
|
|
|
|
2016-10-06 11:39:10 +00:00
|
|
|
$helper->log('Load from Xlsx file');
|
2020-05-24 11:03:07 +00:00
|
|
|
$reader = new XlsxReader();
|
2016-08-31 16:15:54 +00:00
|
|
|
$reader->setIncludeCharts(true);
|
|
|
|
$spreadsheet = $reader->load($filename);
|
2020-05-24 11:03:07 +00:00
|
|
|
unlink($filename);
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
$helper->log('Update cell data values that are displayed in the chart');
|
|
|
|
$worksheet = $spreadsheet->getActiveSheet();
|
|
|
|
$worksheet->fromArray(
|
|
|
|
[
|
2020-05-18 04:49:57 +00:00
|
|
|
[50 - 12, 50 - 15, 50 - 21],
|
|
|
|
[50 - 56, 50 - 73, 50 - 86],
|
|
|
|
[50 - 52, 50 - 61, 50 - 69],
|
|
|
|
[50 - 30, 50 - 32, 50],
|
|
|
|
],
|
2016-08-31 16:15:54 +00:00
|
|
|
null,
|
|
|
|
'B2'
|
|
|
|
);
|
|
|
|
|
|
|
|
// Save Excel 2007 file
|
|
|
|
$filename = $helper->getFilename(__FILE__);
|
2020-05-24 11:03:07 +00:00
|
|
|
$writer = new XlsxWriter($spreadsheet);
|
2016-08-31 16:15:54 +00:00
|
|
|
$writer->setIncludeCharts(true);
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$writer->save($filename);
|
|
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|