private function processTable(Table $table, PHPExcel_Worksheet $phpExcelSheet, &$lineOffset) { $tableStartingLineIndex = $lineOffset; $tableStartingColumnIndex = PHPExcel_Cell::stringFromColumnIndex(0); $tableEndingColumnIndex = PHPExcel_Cell::stringFromColumnIndex(count($table->getColumns()) - 1); // Table label if ($table->getLabel() !== null) { $phpExcelSheet->setCellValueByColumnAndRow(0, $lineOffset, $table->getLabel()); if (count($table->getColumns()) > 1) { $phpExcelSheet->mergeCells($tableStartingColumnIndex . $lineOffset . ':' . $tableEndingColumnIndex . $lineOffset); } $lineOffset++; } // Header. if ($table->displayColumnsLabel()) { $lineOffset++; } // Columns foreach ($table->getColumns() as $columnIndex => $column) { $this->processColumn($table, $columnIndex, $column, $phpExcelSheet, $lineOffset); } // Style. //@todo for now, styles are fixed: make them configurable // Style for Table label. if ($table->getLabel() !== null) { $cellCoordinates = $tableStartingColumnIndex . $tableStartingLineIndex; if (count($table->getColumns()) > 1) { $cellCoordinates .= ':' . $tableEndingColumnIndex . $tableStartingLineIndex; } $phpExcelSheet->getStyle($cellCoordinates)->applyFromArray($this->tableLabelStyle); $tableStartingLineIndex++; } // Style for column header. if ($table->displayColumnsLabel()) { $cellCoordinates = $tableStartingColumnIndex . $tableStartingLineIndex . ':' . $tableEndingColumnIndex . $tableStartingLineIndex; $phpExcelSheet->getStyle($cellCoordinates)->applyFromArray($this->columnHeaderStyle); $tableStartingLineIndex++; } // Border around each lines. foreach ($table->getLines() as $lineIndex => $line) { $lineNumber = $tableStartingLineIndex + $lineIndex; $cellCoordinates = $tableStartingColumnIndex . $lineNumber . ':' . $tableEndingColumnIndex . $lineNumber; $phpExcelSheet->getStyle($cellCoordinates)->applyFromArray($this->cellBorderStyle); } }