https://github.com/viest/php-ext-excel-exportphp
此處拿PHPOffice做爲對比對象,使用相同的方式進行導出(逐行寫入),在數據相同的狀況下,PHPOffice 在2W時,因內存不夠而中止了,而 php-ext-excel-export 在固定內存模式下,輕鬆愜意的完成了導出工做,詳情對比數據看下圖:git
最大使用內存 = 最大單行數據量github
$fileObject = $excel->constMemory('tutorial01.xlsx');
$config = ['path' => '/home/viest/']; $excel = new \Vtiful\Kernel\Excel($config); $excel->fileName('test.xlsx') ->header(['Item', 'Cost']) ->data([ ['Rent', 1000], ['Gas', 100], ['Food', 300], ['Gym', 50], ]) ->output();
insertImage(int $row, int $column, string $localImagePath)
$excel = new \Vtiful\Kernel\Excel($config); $freeFile = $excel->fileName("free.xlsx"); $freeFile->insertImage(5, 0, '/vagrant/ASW-G-66.jpg'); $freeFile->output();
insertFormula(int $row, int $column, string $formula)
$excel = new \Vtiful\Kernel\Excel($config); $freeFile = $excel->fileName("free.xlsx") ->header(['name', 'money']); for($index = 0; $index < 10; $index++) { $textFile->insertText($index+1, 0, 'vikin'); $textFile->insertText($index+1, 1, 10); } $textFile->insertText(12, 0, "Total"); $textFile->insertFormula(12, 1, '=SUM(B2:B11)'); $freeFile->output();
$config = ['path' => './tests']; $excel = new \Vtiful\Kernel\Excel($config); // 普通模式 $fileObject = $excel->fileName('tutorial01.xlsx'); // 或 固定內存模式 $fileObject = $excel->constMemory('tutorial01.xlsx'); $fileHandle = $fileObject->getHandle(); $boldStyle = \Vtiful\Kernel\Format::bold($fileHandle); $fileObject->header(['name', 'age']) ->data([['viest', 21]]) ->setColumn($boldStyle, 'A:A', 200) ->output();