2016-08-31 16:15:54 +00:00
|
|
|
<?php
|
|
|
|
|
2016-08-31 17:18:12 +00:00
|
|
|
namespace PhpOffice\PhpSpreadsheet;
|
2016-08-31 16:15:54 +00:00
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
use PhpOffice\PhpSpreadsheet\Reader\IReadFilter;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
|
2016-08-31 16:15:54 +00:00
|
|
|
require __DIR__ . '/Header.php';
|
|
|
|
|
|
|
|
// Write temporary file
|
|
|
|
$largeSpreadsheet = require __DIR__ . '/templates/largeSpreadsheet.php';
|
2017-05-17 22:02:17 +00:00
|
|
|
$writer = new Xlsx($largeSpreadsheet);
|
2016-08-31 16:15:54 +00:00
|
|
|
$filename = $helper->getTemporaryFilename();
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$writer->save($filename);
|
|
|
|
$helper->logWrite($writer, $filename, $callStartTime);
|
|
|
|
|
2017-05-17 22:02:17 +00:00
|
|
|
class MyReadFilter implements IReadFilter
|
2016-08-31 16:15:54 +00:00
|
|
|
{
|
|
|
|
public function readCell($column, $row, $worksheetName = '')
|
|
|
|
{
|
|
|
|
// Read title row and rows 20 - 30
|
|
|
|
if ($row == 1 || ($row >= 20 && $row <= 30)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-06 11:39:10 +00:00
|
|
|
$helper->log('Load from Xlsx file');
|
2017-05-17 22:02:17 +00:00
|
|
|
$reader = IOFactory::createReader('Xlsx');
|
2016-08-31 16:15:54 +00:00
|
|
|
$reader->setReadFilter(new MyReadFilter());
|
|
|
|
$callStartTime = microtime(true);
|
|
|
|
$spreadsheet = $reader->load($filename);
|
2016-10-06 11:39:10 +00:00
|
|
|
$helper->logRead('Xlsx', $filename, $callStartTime);
|
2016-08-31 16:15:54 +00:00
|
|
|
$helper->log('Remove unnecessary rows');
|
|
|
|
$spreadsheet->getActiveSheet()->removeRow(2, 18);
|
|
|
|
|
|
|
|
// Save
|
|
|
|
$helper->write($spreadsheet, __FILE__);
|