protected function PHPExcel_Reader_HTML::_processDomElement in Loft Data Grids 7.2
Same name and namespace in other branches
- 6.2 vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php \PHPExcel_Reader_HTML::_processDomElement()
1 call to PHPExcel_Reader_HTML::_processDomElement()
- PHPExcel_Reader_HTML::loadIntoExisting in vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php
- Loads PHPExcel from file into PHPExcel instance
File
- vendor/phpoffice/phpexcel/Classes/PHPExcel/Reader/HTML.php, line 216
Class
- PHPExcel_Reader_HTML
- PHPExcel_Reader_HTML
Code
protected function _processDomElement(DOMNode $element, $sheet, &$row, &$column, &$cellContent, $format = null) {
foreach ($element->childNodes as $child) {
if ($child instanceof DOMText) {
$domText = preg_replace('/\\s+/u', ' ', trim($child->nodeValue));
if (is_string($cellContent)) {
$cellContent .= $domText;
}
else {
}
}
elseif ($child instanceof DOMElement) {
$attributeArray = array();
foreach ($child->attributes as $attribute) {
$attributeArray[$attribute->name] = $attribute->value;
}
switch ($child->nodeName) {
case 'meta':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'content':
break;
}
}
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'title':
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
$sheet
->setTitle($cellContent);
$cellContent = '';
break;
case 'span':
case 'div':
case 'font':
case 'i':
case 'em':
case 'strong':
case 'b':
if ($cellContent > '') {
$cellContent .= ' ';
}
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
if ($cellContent > '') {
$cellContent .= ' ';
}
break;
case 'hr':
$this
->_flushCell($sheet, $column, $row, $cellContent);
++$row;
if (isset($this->_formats[$child->nodeName])) {
$sheet
->getStyle($column . $row)
->applyFromArray($this->_formats[$child->nodeName]);
}
else {
$cellContent = '----------';
$this
->_flushCell($sheet, $column, $row, $cellContent);
}
++$row;
case 'br':
if ($this->_tableLevel > 0) {
$cellContent .= "\n";
}
else {
$this
->_flushCell($sheet, $column, $row, $cellContent);
++$row;
}
break;
case 'a':
foreach ($attributeArray as $attributeName => $attributeValue) {
switch ($attributeName) {
case 'href':
$sheet
->getCell($column . $row)
->getHyperlink()
->setUrl($attributeValue);
if (isset($this->_formats[$child->nodeName])) {
$sheet
->getStyle($column . $row)
->applyFromArray($this->_formats[$child->nodeName]);
}
break;
}
}
$cellContent .= ' ';
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'h1':
case 'h2':
case 'h3':
case 'h4':
case 'h5':
case 'h6':
case 'ol':
case 'ul':
case 'p':
if ($this->_tableLevel > 0) {
$cellContent .= "\n";
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
}
else {
if ($cellContent > '') {
$this
->_flushCell($sheet, $column, $row, $cellContent);
$row++;
}
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this
->_flushCell($sheet, $column, $row, $cellContent);
if (isset($this->_formats[$child->nodeName])) {
$sheet
->getStyle($column . $row)
->applyFromArray($this->_formats[$child->nodeName]);
}
$row++;
$column = 'A';
}
break;
case 'li':
if ($this->_tableLevel > 0) {
$cellContent .= "\n";
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
}
else {
if ($cellContent > '') {
$this
->_flushCell($sheet, $column, $row, $cellContent);
}
++$row;
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
$this
->_flushCell($sheet, $column, $row, $cellContent);
$column = 'A';
}
break;
case 'table':
$this
->_flushCell($sheet, $column, $row, $cellContent);
$column = $this
->_setTableStartColumn($column);
if ($this->_tableLevel > 1) {
--$row;
}
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
$column = $this
->_releaseTableStartColumn();
if ($this->_tableLevel > 1) {
++$column;
}
else {
++$row;
}
break;
case 'thead':
case 'tbody':
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
case 'tr':
$column = $this
->_getTableStartColumn();
$cellContent = '';
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
++$row;
break;
case 'th':
case 'td':
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
while (isset($this->rowspan[$column . $row])) {
++$column;
}
$this
->_flushCell($sheet, $column, $row, $cellContent);
if (isset($attributeArray['rowspan']) && isset($attributeArray['colspan'])) {
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$range = $column . $row . ':' . $columnTo . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet
->mergeCells($range);
$column = $columnTo;
}
elseif (isset($attributeArray['rowspan'])) {
$range = $column . $row . ':' . $column . ($row + $attributeArray['rowspan'] - 1);
foreach (\PHPExcel_Cell::extractAllCellReferencesInRange($range) as $value) {
$this->rowspan[$value] = true;
}
$sheet
->mergeCells($range);
}
elseif (isset($attributeArray['colspan'])) {
$columnTo = $column;
for ($i = 0; $i < $attributeArray['colspan'] - 1; $i++) {
++$columnTo;
}
$sheet
->mergeCells($column . $row . ':' . $columnTo . $row);
$column = $columnTo;
}
++$column;
break;
case 'body':
$row = 1;
$column = 'A';
$content = '';
$this->_tableLevel = 0;
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
break;
default:
$this
->_processDomElement($child, $sheet, $row, $column, $cellContent);
}
}
}
}