' . "\r\n";
}
// Write cells
$colNum = 0;
foreach ($pValues as $cell) {
if (!$this->_useInlineCss) {
$cssClass = '';
$cssClass = 'column' . $colNum;
} else {
$cssClass = array();
if (isset($this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum])) {
$this->_cssStyles['table.sheet' . $sheetIndex . ' td.column' . $colNum];
}
}
$colSpan = 1;
$rowSpan = 1;
$writeCell = true; // Write cell
// initialize
$cellData = '';
// PHPExcel_Cell
if ($cell instanceof PHPExcel_Cell) {
// Value
if ($cell->getValue() instanceof PHPExcel_RichText) {
// Loop through rich text elements
$elements = $cell->getValue()->getRichTextElements();
foreach ($elements as $element) {
// Rich text start?
if ($element instanceof PHPExcel_RichText_Run) {
$cellData .= '';
if ($element->getFont()->getSuperScript()) {
$cellData .= '';
} else if ($element->getFont()->getSubScript()) {
$cellData .= '';
}
}
// Convert UTF8 data to PCDATA
$cellText = $element->getText();
$cellData .= htmlspecialchars($cellText);
if ($element instanceof PHPExcel_RichText_Run) {
if ($element->getFont()->getSuperScript()) {
$cellData .= '';
} else if ($element->getFont()->getSubScript()) {
$cellData .= '';
}
$cellData .= '';
}
}
} else {
if ($this->_preCalculateFormulas) {
$cellData = PHPExcel_Style_NumberFormat::toFormattedString(
$cell->getCalculatedValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
array($this, 'formatColor')
);
} else {
$cellData = PHPExcel_Style_NumberFormat::ToFormattedString(
$cell->getValue(),
$pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() )->getNumberFormat()->getFormatCode(),
array($this, 'formatColor')
);
}
}
// replace leading spaces on each line with
$cellData = $this->_convertNbsp($cellData);
// convert newline "\n" to '
'
$cellData = str_replace("\n", '
', $cellData);
// Check value
if ($cellData == '') {
$cellData = ' ';
}
// Extend CSS class?
if (!$this->_useInlineCss) {
$cssClass .= ' style' . $cell->getXfIndex();
$cssClass .= ' ' . $cell->getDataType();
} else {
if (isset($this->_cssStyles['td.style' . $cell->getXfIndex()])) {
$cssClass = array_merge($cssClass, $this->_cssStyles['td.style' . $cell->getXfIndex()]);
}
// General horizontal alignment: Actual horizontal alignment depends on dataType
$sharedStyle = $pSheet->getParent()->getCellXfByIndex( $cell->getXfIndex() );
if ($sharedStyle->getAlignment()->getHorizontal() == PHPExcel_Style_Alignment::HORIZONTAL_GENERAL
&& isset($this->_cssStyles['.' . $cell->getDataType()]['text-align']))
{
$cssClass['text-align'] = $this->_cssStyles['.' . $cell->getDataType()]['text-align'];
}
}
} else {
$cell = new PHPExcel_Cell(
PHPExcel_Cell::stringFromColumnIndex($colNum),
($pRow + 1),
'',
PHPExcel_Cell_DataType::TYPE_NULL,
$pSheet
);
}
// Hyperlink?
if ($cell->hasHyperlink() && !$cell->getHyperlink()->isInternal()) {
$cellData = '' . $cellData . '';
}
// Should the cell be written or is it swallowed by a rowspan or colspan?
$writeCell = ! ( isset($this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])
&& $this->_isSpannedCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum] );
// Colspan and Rowspan
$colspan = 1;
$rowspan = 1;
if (isset($this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum])) {
$spans = $this->_isBaseCell[$pSheet->getParent()->getIndex($pSheet)][$pRow + 1][$colNum];
$rowSpan = $spans['rowspan'];
$colSpan = $spans['colspan'];
}
// Write
if ($writeCell) {
// Column start
$html .= ' _useInlineCss) {
$html .= ' class="' . $cssClass . '"';
} else {
//** Necessary redundant code for the sake of PHPExcel_Writer_PDF **
// We must explicitly write the width of the | element because TCPDF
// does not recognize e.g.
$width = 0;
$columnIndex = PHPExcel_Cell::columnIndexFromString($cell->getColumn()) - 1;
for ($i = $columnIndex; $i < $columnIndex + $colSpan; ++$i) {
if (isset($this->_columnWidths[$sheetIndex][$i])) {
$width += $this->_columnWidths[$sheetIndex][$i];
}
}
$cssClass['width'] = $width . 'pt';
// We must also explicitly write the height of the | element because TCPDF
// does not recognize e.g. |