/** * Constructor * * @param int &$str_total Total number of strings * @param int &$str_unique Total number of unique strings * @param array &$str_table String Table * @param array &$colors Colour Table * @param mixed $parser The formula parser created for the Workbook * @param boolean $preCalculateFormulas Flag indicating whether formulas should be calculated or just written * @param string $phpSheet The worksheet to write * @param \PHPExcel\Worksheet $phpSheet */ public function __construct(&$str_total, &$str_unique, &$str_table, &$colors, $parser, $preCalculateFormulas, $phpSheet) { // It needs to call its parent's constructor explicitly parent::__construct(); // change BIFFwriter limit for CONTINUE records // $this->_limit = 8224; $this->_preCalculateFormulas = $preCalculateFormulas; $this->stringTotal =& $str_total; $this->stringUnique =& $str_unique; $this->stringTable =& $str_table; $this->colors =& $colors; $this->parser = $parser; $this->phpSheet = $phpSheet; //$this->ext_sheets = array(); //$this->offset = 0; $this->xlsStringMaxLength = 255; $this->columnInfo = array(); $this->selection = array(0, 0, 0, 0); $this->activePane = 3; $this->_print_headers = 0; $this->outlineStyle = 0; $this->outlineBelow = 1; $this->outlineRight = 1; $this->outlineOn = 1; $this->fontHashIndex = array(); // calculate values for DIMENSIONS record $minR = 1; $minC = 'A'; $maxR = $this->phpSheet->getHighestRow(); $maxC = $this->phpSheet->getHighestColumn(); // Determine lowest and highest column and row // $this->firstRowIndex = ($minR > 65535) ? 65535 : $minR; $this->lastRowIndex = $maxR > 65535 ? 65535 : $maxR; $this->firstColumnIndex = \PHPExcel\Cell::columnIndexFromString($minC); $this->lastColumnIndex = \PHPExcel\Cell::columnIndexFromString($maxC); // if ($this->firstColumnIndex > 255) $this->firstColumnIndex = 255; if ($this->lastColumnIndex > 255) { $this->lastColumnIndex = 255; } $this->countCellStyleXfs = count($phpSheet->getParent()->getCellStyleXfCollection()); }
/** * (Re)Set the end row * * @param integer $endRow The row number at which to stop iterating * @return RowIterator */ public function resetEnd($endRow = null) { $this->endRow = $endRow ? $endRow : $this->subject->getHighestRow(); return $this; }
/** * Write SheetData * * @param \PHPExcel\Shared\XMLWriter $objWriter XML Writer * @param \PHPExcel\Worksheet $pSheet Worksheet * @param string[] $pStringTable String table * @throws \PHPExcel\Writer\Exception */ private function writeSheetData(\PHPExcel\Shared\XMLWriter $objWriter = null, \PHPExcel\Worksheet $pSheet = null, $pStringTable = null) { if (is_array($pStringTable)) { // Flipped stringtable, for faster index searching $aFlippedStringTable = $this->getParentWriter()->getWriterPart('stringtable')->flipStringTable($pStringTable); // sheetData $objWriter->startElement('sheetData'); // Get column count $colCount = \PHPExcel\Cell::columnIndexFromString($pSheet->getHighestColumn()); // Highest row number $highestRow = $pSheet->getHighestRow(); // Loop through cells $cellsByRow = array(); foreach ($pSheet->getCellCollection() as $cellID) { $cellAddress = \PHPExcel\Cell::coordinateFromString($cellID); $cellsByRow[$cellAddress[1]][] = $cellID; } $currentRow = 0; while ($currentRow++ < $highestRow) { // Get row dimension $rowDimension = $pSheet->getRowDimension($currentRow); // Write current row? $writeCurrentRow = isset($cellsByRow[$currentRow]) || $rowDimension->getRowHeight() >= 0 || $rowDimension->getVisible() == false || $rowDimension->getCollapsed() == true || $rowDimension->getOutlineLevel() > 0 || $rowDimension->getXfIndex() !== null; if ($writeCurrentRow) { // Start a new row $objWriter->startElement('row'); $objWriter->writeAttribute('r', $currentRow); $objWriter->writeAttribute('spans', '1:' . $colCount); // Row dimensions if ($rowDimension->getRowHeight() >= 0) { $objWriter->writeAttribute('customHeight', '1'); $objWriter->writeAttribute('ht', \PHPExcel\Shared\StringHelper::formatNumber($rowDimension->getRowHeight())); } // Row visibility if ($rowDimension->getVisible() == false) { $objWriter->writeAttribute('hidden', 'true'); } // Collapsed if ($rowDimension->getCollapsed() == true) { $objWriter->writeAttribute('collapsed', 'true'); } // Outline level if ($rowDimension->getOutlineLevel() > 0) { $objWriter->writeAttribute('outlineLevel', $rowDimension->getOutlineLevel()); } // Style if ($rowDimension->getXfIndex() !== null) { $objWriter->writeAttribute('s', $rowDimension->getXfIndex()); $objWriter->writeAttribute('customFormat', '1'); } // Write cells if (isset($cellsByRow[$currentRow])) { foreach ($cellsByRow[$currentRow] as $cellAddress) { // Write cell $this->writeCell($objWriter, $pSheet, $cellAddress, $pStringTable, $aFlippedStringTable); } } // End row $objWriter->endElement(); } } $objWriter->endElement(); } else { throw new \PHPExcel\Writer\Exception("Invalid parameters passed."); } }