Last active
December 12, 2019 07:36
-
-
Save pqr/ad12493947e7b1e2910f to your computer and use it in GitHub Desktop.
optimized example for http://habrahabr.ru/post/269051/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
$callStartTime = microtime(true); | |
$objPHPExcel = PHPExcel_IOFactory::load('multipage.xls'); | |
$sheetsIterator = $objPHPExcel->getWorksheetIterator(); | |
$tmpFileName = microtime(true); | |
while( $sheetsIterator->valid()) { | |
// Create new object to write converted data and separate documents sheets | |
$csvPagePhpExcel = new PHPExcel(); | |
$sheet = $sheetsIterator->current(); | |
$csvPagePhpExcel->addSheet($sheet, 0); | |
// Creating CSV writer Object and save data to file | |
$objWriter = PHPExcel_IOFactory::createWriter($csvPagePhpExcel, 'CSV'); | |
$currentTmpFileName = "{$tmpFileName}_sheet_{$sheetsIterator->key()}.csv"; | |
$objWriter->save($currentTmpFileName); | |
$sheetsIterator->next(); | |
} | |
$callEndTime = microtime(true); | |
$callTime = $callEndTime - $callStartTime; | |
echo "\n" . $callTime . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice!