2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require __DIR__ . '/Header.php';
|
|
|
|
$spreadsheet = require __DIR__ . '/templates/sampleSpreadsheet.php';
|
|
|
|
|
|
|
|
$helper->log('Write to CSV format');
|
2017-01-22 08:39:23 +00:00
|
|
|
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
|
2016-08-31 16:15:54 +00:00
|
|
|
->setEnclosure('"')
|
|
|
|
->setSheetIndex(0);
|
|
|
|
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$filename = $helper->getTemporaryFilename('csv');
|
|
|
|
$writer->save($filename);
|
|
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
|
|
|
|
$helper->log('Read from CSV format');
|
|
|
|
|
2017-01-22 08:39:23 +00:00
|
|
|
$reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Csv')->setDelimiter(',')
|
2016-08-31 16:15:54 +00:00
|
|
|
->setEnclosure('"')
|
|
|
|
->setSheetIndex(0);
|
|
|
|
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$spreadsheetFromCSV = $reader->load($filename);
|
2017-01-22 08:39:23 +00:00
|
|
|
$helper->logRead('Csv', $filename, $callStartTime);
|
2016-08-31 16:15:54 +00:00
|
|
|
|
2016-10-06 11:39:10 +00:00
|
|
|
// Write Xlsx
|
2017-01-22 08:39:23 +00:00
|
|
|
$helper->write($spreadsheetFromCSV, __FILE__, ['Xlsx']);
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
// Write CSV
|
|
|
|
$filenameCSV = $helper->getFilename(__FILE__, 'csv');
|
2017-01-22 08:39:23 +00:00
|
|
|
$writerCSV = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheetFromCSV, 'Csv');
|
2016-08-31 16:15:54 +00:00
|
|
|
$writerCSV->setExcelCompatibility(true);
|
|
|
|
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$writerCSV->save($filenameCSV);
|
|
|
|
$helper->logWrite($writerCSV, $filenameCSV, $callStartTime);
|