php - Only save changes in PHPExcel -
i using phpexcel editing large xlsx file (~230kb, 20 sheets). way yet is:
- load file (create phpexcel object)
- do changes on phpexcel object
- overwrite xlsx file new one
this slow (~6 seconds), although there small changes (some cells in 1 worksheet).
is there way save changes in file? or if not, library?
you can try spout: https://github.com/box/spout. should not take more second , code should this:
$reader = readerfactory::create(type::xlsx); $reader->open('path/to/file/to/read.xlsx'); $writer = writerfactory::create(type::xlsx); $writer->opentofile('path/to/file/to/write.xlsx'); // needs different 1 read while ($reader->hasnextsheet()) { $reader->nextsheet(); while ($reader->hasnextrow()) { $row = $reader->nextrow(); // change row here if needed $writer->addrow($row); } } $reader->close(); $writer->close(); // , @ end, can replace old file new one: rename('path/to/file/to/read.xlsx', 'path/to/file/to/write.xlsx');
hope helps!
Comments
Post a Comment