private function PHPExcel_Writer_Excel5_Worksheet::_writeMergedCells in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5/Worksheet.php \PHPExcel_Writer_Excel5_Worksheet::_writeMergedCells()
* Store the MERGEDCELLS records for all ranges of merged cells
1 call to PHPExcel_Writer_Excel5_Worksheet::_writeMergedCells()
- PHPExcel_Writer_Excel5_Worksheet::close in vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Worksheet.php - * Add data to the beginning of the workbook (note the reverse order) * and to the end of the workbook. * * @access public *
File
- vendor/
phpoffice/ phpexcel/ Classes/ PHPExcel/ Writer/ Excel5/ Worksheet.php, line 1503
Class
- PHPExcel_Writer_Excel5_Worksheet
- PHPExcel_Writer_Excel5_Worksheet
Code
private function _writeMergedCells() {
$mergeCells = $this->_phpSheet
->getMergeCells();
$countMergeCells = count($mergeCells);
if ($countMergeCells == 0) {
return;
}
// maximum allowed number of merged cells per record
$maxCountMergeCellsPerRecord = 1027;
// record identifier
$record = 0xe5;
// counter for total number of merged cells treated so far by the writer
$i = 0;
// counter for number of merged cells written in record currently being written
$j = 0;
// initialize record data
$recordData = '';
// loop through the merged cells
foreach ($mergeCells as $mergeCell) {
++$i;
++$j;
// extract the row and column indexes
$range = PHPExcel_Cell::splitRange($mergeCell);
list($first, $last) = $range[0];
list($firstColumn, $firstRow) = PHPExcel_Cell::coordinateFromString($first);
list($lastColumn, $lastRow) = PHPExcel_Cell::coordinateFromString($last);
$recordData .= pack('vvvv', $firstRow - 1, $lastRow - 1, PHPExcel_Cell::columnIndexFromString($firstColumn) - 1, PHPExcel_Cell::columnIndexFromString($lastColumn) - 1);
// flush record if we have reached limit for number of merged cells, or reached final merged cell
if ($j == $maxCountMergeCellsPerRecord or $i == $countMergeCells) {
$recordData = pack('v', $j) . $recordData;
$length = strlen($recordData);
$header = pack('vv', $record, $length);
$this
->_append($header . $recordData);
// initialize for next record, if any
$recordData = '';
$j = 0;
}
}
}