PhpSpreadsheet/samples/Basic/20_Read_Xls.php

24 lines
618 B
PHP
Raw Normal View History

<?php
use PhpOffice\PhpSpreadsheet\IOFactory;
2017-10-01 08:48:59 +00:00
require __DIR__ . '/../Header.php';
2017-10-01 08:48:59 +00:00
$spreadsheet = require __DIR__ . '/../templates/sampleSpreadsheet.php';
// Write temporary file
$filename = $helper->getTemporaryFilename('xls');
$writer = IOFactory::createWriter($spreadsheet, 'Xls');
$callStartTime = microtime(true);
$writer->save($filename);
$helper->logWrite($writer, $filename, $callStartTime);
2016-10-06 11:49:41 +00:00
// Read Xls file
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
2016-10-06 11:49:41 +00:00
$helper->logRead('Xls', $filename, $callStartTime);
unlink($filename);
// Save
$helper->write($spreadsheet, __FILE__);