2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
|
2017-10-01 08:48:59 +00:00
|
|
|
require __DIR__ . '/../Header.php';
|
|
|
|
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
$helper->log('Write to CSV format');
|
2017-05-17 22:02:17 +00:00
|
|
|
$writer = IOFactory::createWriter($spreadsheet, 'Csv')->setDelimiter(',')
|
2018-01-28 06:59:38 +00:00
|
|
|
->setEnclosure('"')
|
|
|
|
->setSheetIndex(0);
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$filename = $helper->getTemporaryFilename('csv');
|
|
|
|
$writer->save($filename);
|
|
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
|
|
|
|
$helper->log('Read from CSV format');
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
$reader = IOFactory::createReader('Csv')->setDelimiter(',')
|
2018-01-28 06:59:38 +00:00
|
|
|
->setEnclosure('"')
|
|
|
|
->setSheetIndex(0);
|
2016-08-31 16:15:54 +00:00
|
|
|
|
|
|
|
$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-05-17 22:02:17 +00:00
|
|
|
$writerCSV = 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);
|