mirror of
https://github.com/retailcrm/PHPExcel.git
synced 2024-11-23 05:46:06 +03:00
Minor performance tweaks to the HTML Writer
git-svn-id: https://phpexcel.svn.codeplex.com/svn/trunk@63950 2327b42d-5241-43d6-9e2a-de5ac946f064
This commit is contained in:
parent
dbcd7fb1af
commit
951c332cda
@ -304,6 +304,20 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
private $_tabColor;
|
private $_tabColor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dirty flag
|
||||||
|
*
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $_dirty = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hash
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $_hash = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new worksheet
|
* Create a new worksheet
|
||||||
*
|
*
|
||||||
@ -644,7 +658,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
{
|
{
|
||||||
// Is this a 'rename' or not?
|
// Is this a 'rename' or not?
|
||||||
if ($this->getTitle() == $pValue) {
|
if ($this->getTitle() == $pValue) {
|
||||||
return;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Syntax check
|
// Syntax check
|
||||||
@ -675,13 +689,12 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
}
|
}
|
||||||
|
|
||||||
$altTitle = $pValue . ' ' . $i;
|
$altTitle = $pValue . ' ' . $i;
|
||||||
$this->setTitle($altTitle);
|
return $this->setTitle($altTitle);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set title
|
// Set title
|
||||||
$this->_title = $pValue;
|
$this->_title = $pValue;
|
||||||
|
$this->_dirty = true;
|
||||||
|
|
||||||
// New title
|
// New title
|
||||||
$newTitle = $this->getTitle();
|
$newTitle = $this->getTitle();
|
||||||
@ -817,6 +830,8 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
public function setProtection(PHPExcel_Worksheet_Protection $pValue)
|
public function setProtection(PHPExcel_Worksheet_Protection $pValue)
|
||||||
{
|
{
|
||||||
$this->_protection = $pValue;
|
$this->_protection = $pValue;
|
||||||
|
$this->_dirty = true;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1629,6 +1644,7 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
|
|
||||||
if (strpos($pRange,':') !== false) {
|
if (strpos($pRange,':') !== false) {
|
||||||
$this->_autoFilter = $pRange;
|
$this->_autoFilter = $pRange;
|
||||||
|
$this->_dirty = true;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Autofilter must be set on a range of cells.');
|
throw new Exception('Autofilter must be set on a range of cells.');
|
||||||
}
|
}
|
||||||
@ -2176,25 +2192,29 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public function garbageCollect() {
|
public function garbageCollect() {
|
||||||
// Build a reference table from images
|
// Build a reference table from images
|
||||||
$imageCoordinates = array();
|
// $imageCoordinates = array();
|
||||||
$iterator = $this->getDrawingCollection()->getIterator();
|
// $iterator = $this->getDrawingCollection()->getIterator();
|
||||||
while ($iterator->valid()) {
|
// while ($iterator->valid()) {
|
||||||
$imageCoordinates[$iterator->current()->getCoordinates()] = true;
|
// $imageCoordinates[$iterator->current()->getCoordinates()] = true;
|
||||||
|
//
|
||||||
$iterator->next();
|
// $iterator->next();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Lookup highest column and highest row if cells are cleaned
|
// Lookup highest column and highest row if cells are cleaned
|
||||||
$highestColumn = -1;
|
$highestColumn = -1;
|
||||||
$highestRow = 1;
|
$highestRow = 1;
|
||||||
|
|
||||||
// Find cells that can be cleaned
|
// Find cells that can be cleaned
|
||||||
|
$col = $row = array();
|
||||||
foreach ($this->_cellCollection->getCellList() as $coord) {
|
foreach ($this->_cellCollection->getCellList() as $coord) {
|
||||||
list($col,$row) = sscanf($coord,'%[A-Z]%d');
|
list($c,$r) = sscanf($coord,'%[A-Z]%d');
|
||||||
// Determine highest column and row
|
$row[$r] = $r;
|
||||||
$highestColumn = max($highestColumn,PHPExcel_Cell::columnIndexFromString($col));
|
$col[$c] = strlen($c).$c;
|
||||||
$highestRow = max($highestRow,$row);
|
|
||||||
}
|
}
|
||||||
|
// Determine highest column and row
|
||||||
|
$highestRow = max($row);
|
||||||
|
$highestColumn = PHPExcel_Cell::columnIndexFromString(substr(max($col),1));
|
||||||
|
|
||||||
|
|
||||||
// Loop through column dimensions
|
// Loop through column dimensions
|
||||||
foreach ($this->_columnDimensions as $dimension) {
|
foreach ($this->_columnDimensions as $dimension) {
|
||||||
@ -2224,20 +2244,22 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
* @return string Hash code
|
* @return string Hash code
|
||||||
*/
|
*/
|
||||||
public function getHashCode() {
|
public function getHashCode() {
|
||||||
return md5(
|
if ($this->_dirty) {
|
||||||
$this->_title
|
$this->_hash = md5( $this->_title .
|
||||||
. $this->_autoFilter
|
$this->_autoFilter .
|
||||||
. ($this->_protection->isProtectionEnabled() ? 't' : 'f')
|
($this->_protection->isProtectionEnabled() ? 't' : 'f') .
|
||||||
//. $this->calculateWorksheetDimension()
|
__CLASS__
|
||||||
. __CLASS__
|
|
||||||
);
|
);
|
||||||
|
$this->_dirty = false;
|
||||||
|
}
|
||||||
|
return $this->_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extract worksheet title from range.
|
* Extract worksheet title from range.
|
||||||
*
|
*
|
||||||
* Example: extractSheetTitle('test!A1') ==> 'A1'
|
* Example: extractSheetTitle("testSheet!A1") ==> 'A1'
|
||||||
* Example: extractSheetTitle('test!A1', true) ==> array('test', 'A1');
|
* Example: extractSheetTitle("'testSheet 1'!A1", true) ==> array('testSheet 1', 'A1');
|
||||||
*
|
*
|
||||||
* @param string $pRange Range to extract title from
|
* @param string $pRange Range to extract title from
|
||||||
* @param bool $returnRange Return range? (see example)
|
* @param bool $returnRange Return range? (see example)
|
||||||
@ -2245,30 +2267,17 @@ class PHPExcel_Worksheet implements PHPExcel_IComparable
|
|||||||
*/
|
*/
|
||||||
public static function extractSheetTitle($pRange, $returnRange = false) {
|
public static function extractSheetTitle($pRange, $returnRange = false) {
|
||||||
// Sheet title included?
|
// Sheet title included?
|
||||||
if (strpos($pRange, '!') === false) {
|
if (($sep = strpos($pRange, '!')) === false) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Position of separator exclamation mark
|
|
||||||
$sep = strrpos($pRange, '!');
|
|
||||||
|
|
||||||
// Extract sheet title
|
|
||||||
$reference[0] = substr($pRange, 0, $sep);
|
|
||||||
$reference[1] = substr($pRange, $sep + 1);
|
|
||||||
|
|
||||||
// Strip possible enclosing single quotes
|
|
||||||
if (strpos($reference[0], '\'') === 0) {
|
|
||||||
$reference[0] = substr($reference[0], 1);
|
|
||||||
}
|
|
||||||
if (strrpos($reference[0], '\'') === strlen($reference[0]) - 1) {
|
|
||||||
$reference[0] = substr($reference[0], 0, strlen($reference[0]) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($returnRange) {
|
if ($returnRange) {
|
||||||
return $reference;
|
return array( trim(substr($pRange, 0, $sep),"'"),
|
||||||
} else {
|
substr($pRange, $sep + 1)
|
||||||
return $reference[1];
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return substr($pRange, $sep + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -309,18 +309,18 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Construct HTML
|
// Construct HTML
|
||||||
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . "\r\n";
|
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">' . PHP_EOL;
|
||||||
$html .= '<!-- Generated by PHPExcel - http://www.phpexcel.net -->' . "\r\n";
|
$html .= '<!-- Generated by PHPExcel - http://www.phpexcel.net -->' . PHP_EOL;
|
||||||
$html .= '<html>' . "\r\n";
|
$html .= '<html>' . PHP_EOL;
|
||||||
$html .= ' <head>' . "\r\n";
|
$html .= ' <head>' . PHP_EOL;
|
||||||
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . "\r\n";
|
$html .= ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8">' . PHP_EOL;
|
||||||
$html .= ' <title>' . htmlspecialchars($this->_phpExcel->getProperties()->getTitle()) . '</title>' . "\r\n";
|
$html .= ' <title>' . htmlspecialchars($this->_phpExcel->getProperties()->getTitle()) . '</title>' . PHP_EOL;
|
||||||
if ($pIncludeStyles) {
|
if ($pIncludeStyles) {
|
||||||
$html .= $this->generateStyles(true);
|
$html .= $this->generateStyles(true);
|
||||||
}
|
}
|
||||||
$html .= ' </head>' . "\r\n";
|
$html .= ' </head>' . PHP_EOL;
|
||||||
$html .= '' . "\r\n";
|
$html .= '' . PHP_EOL;
|
||||||
$html .= ' <body>' . "\r\n";
|
$html .= ' <body>' . PHP_EOL;
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $html;
|
return $html;
|
||||||
@ -374,8 +374,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
// calculate start of <tbody>, <thead>
|
// calculate start of <tbody>, <thead>
|
||||||
$tbodyStart = $rowMin;
|
$tbodyStart = $rowMin;
|
||||||
$tbodyEnd = $rowMax;
|
$tbodyEnd = $rowMax;
|
||||||
$theadStart = 0; // default: no <thead>
|
$theadStart = $theadEnd = 0; // default: no <thead> no </thead>
|
||||||
$theadEnd = 0; // default: no </thead>
|
|
||||||
if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
if ($sheet->getPageSetup()->isRowsToRepeatAtTopSet()) {
|
||||||
$rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
|
$rowsToRepeatAtTop = $sheet->getPageSetup()->getRowsToRepeatAtTop();
|
||||||
|
|
||||||
@ -388,44 +387,43 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Loop through cells
|
// Loop through cells
|
||||||
$rowData = null;
|
$row = $rowMin-1;
|
||||||
for ($row = $rowMin; $row <= $rowMax; ++$row) {
|
while($row++ < $rowMax) {
|
||||||
// Start a new row
|
|
||||||
$rowData = array();
|
|
||||||
|
|
||||||
// Loop through columns
|
|
||||||
for ($column = $dimension[0][0]; $column <= $dimension[1][0]; ++$column) {
|
|
||||||
// Cell exists?
|
|
||||||
if ($sheet->cellExistsByColumnAndRow($column, $row)) {
|
|
||||||
$rowData[$column] = $cell = $sheet->getCellByColumnAndRow($column, $row);
|
|
||||||
} else {
|
|
||||||
$rowData[$column] = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// <thead> ?
|
// <thead> ?
|
||||||
if ($row == $theadStart) {
|
if ($row == $theadStart) {
|
||||||
$html .= ' <thead>' . "\r\n";
|
$html .= ' <thead>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// <tbody> ?
|
// <tbody> ?
|
||||||
if ($row == $tbodyStart) {
|
if ($row == $tbodyStart) {
|
||||||
$html .= ' <tbody>' . "\r\n";
|
$html .= ' <tbody>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write row if there are HTML table cells in it
|
// Write row if there are HTML table cells in it
|
||||||
if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) {
|
if ( !isset($this->_isSpannedRow[$sheet->getParent()->getIndex($sheet)][$row]) ) {
|
||||||
|
// Start a new rowData
|
||||||
|
$rowData = array();
|
||||||
|
// Loop through columns
|
||||||
|
$column = $dimension[0][0] - 1;
|
||||||
|
while($column++ < $dimension[1][0]) {
|
||||||
|
// Cell exists?
|
||||||
|
if ($sheet->cellExistsByColumnAndRow($column, $row)) {
|
||||||
|
$rowData[$column] = $sheet->getCellByColumnAndRow($column, $row);
|
||||||
|
} else {
|
||||||
|
$rowData[$column] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
|
$html .= $this->_generateRow($sheet, $rowData, $row - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// </thead> ?
|
// </thead> ?
|
||||||
if ($row == $theadEnd) {
|
if ($row == $theadEnd) {
|
||||||
$html .= ' </thead>' . "\r\n";
|
$html .= ' </thead>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// </tbody> ?
|
// </tbody> ?
|
||||||
if ($row == $tbodyEnd) {
|
if ($row == $tbodyEnd) {
|
||||||
$html .= ' </tbody>' . "\r\n";
|
$html .= ' </tbody>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,8 +431,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
$html .= $this->_generateTableFooter();
|
$html .= $this->_generateTableFooter();
|
||||||
|
|
||||||
// Writing PDF?
|
// Writing PDF?
|
||||||
if ($this->_isPdf)
|
if ($this->_isPdf) {
|
||||||
{
|
|
||||||
if (is_null($this->_sheetIndex) && $sheetId + 1 < $this->_phpExcel->getSheetCount()) {
|
if (is_null($this->_sheetIndex) && $sheetId + 1 < $this->_phpExcel->getSheetCount()) {
|
||||||
$html .= '<tcpdf method="AddPage" />';
|
$html .= '<tcpdf method="AddPage" />';
|
||||||
}
|
}
|
||||||
@ -477,14 +474,14 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
// Loop all sheets
|
// Loop all sheets
|
||||||
$sheetId = 0;
|
$sheetId = 0;
|
||||||
|
|
||||||
$html .= '<ul class="navigation">' . "\r\n";
|
$html .= '<ul class="navigation">' . PHP_EOL;
|
||||||
|
|
||||||
foreach ($sheets as $sheet) {
|
foreach ($sheets as $sheet) {
|
||||||
$html .= ' <li class="sheet' . $sheetId . '"><a href="#sheet' . $sheetId . '">' . $sheet->getTitle() . '</a></li>' . "\r\n";
|
$html .= ' <li class="sheet' . $sheetId . '"><a href="#sheet' . $sheetId . '">' . $sheet->getTitle() . '</a></li>' . PHP_EOL;
|
||||||
++$sheetId;
|
++$sheetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
$html .= '</ul>' . "\r\n";
|
$html .= '</ul>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
@ -524,8 +521,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
// Convert UTF8 data to PCDATA
|
// Convert UTF8 data to PCDATA
|
||||||
$filename = htmlspecialchars($filename);
|
$filename = htmlspecialchars($filename);
|
||||||
|
|
||||||
$html .= "\r\n";
|
$html .= PHP_EOL;
|
||||||
$html .= ' <img style="position: relative; left: ' . $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' . $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' . $filename . '" border="0" width="' . $drawing->getWidth() . '" height="' . $drawing->getHeight() . '" />' . "\r\n";
|
$html .= ' <img style="position: relative; left: ' . $drawing->getOffsetX() . 'px; top: ' . $drawing->getOffsetY() . 'px; width: ' . $drawing->getWidth() . 'px; height: ' . $drawing->getHeight() . 'px;" src="' . $filename . '" border="0" width="' . $drawing->getWidth() . '" height="' . $drawing->getHeight() . '" />' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -555,20 +552,20 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
|
|
||||||
// Start styles
|
// Start styles
|
||||||
if ($generateSurroundingHTML) {
|
if ($generateSurroundingHTML) {
|
||||||
$html .= ' <style type="text/css">' . "\r\n";
|
$html .= ' <style type="text/css">' . PHP_EOL;
|
||||||
$html .= ' html { ' . $this->_assembleCSS($css['html']) . ' }' . "\r\n";
|
$html .= ' html { ' . $this->_assembleCSS($css['html']) . ' }' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write all other styles
|
// Write all other styles
|
||||||
foreach ($css as $styleName => $styleDefinition) {
|
foreach ($css as $styleName => $styleDefinition) {
|
||||||
if ($styleName != 'html') {
|
if ($styleName != 'html') {
|
||||||
$html .= ' ' . $styleName . ' { ' . $this->_assembleCSS($styleDefinition) . ' }' . "\r\n";
|
$html .= ' ' . $styleName . ' { ' . $this->_assembleCSS($styleDefinition) . ' }' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// End styles
|
// End styles
|
||||||
if ($generateSurroundingHTML) {
|
if ($generateSurroundingHTML) {
|
||||||
$html .= ' </style>' . "\r\n";
|
$html .= ' </style>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
@ -659,7 +656,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
|
|
||||||
// col elements, initialize
|
// col elements, initialize
|
||||||
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
|
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($sheet->getHighestColumn()) - 1;
|
||||||
for ($column = 0; $column <= $highestColumnIndex; ++$column) {
|
$column = -1;
|
||||||
|
while($column++ < $highestColumnIndex) {
|
||||||
$this->_columnWidths[$sheetIndex][$column] = 42; // approximation
|
$this->_columnWidths[$sheetIndex][$column] = 42; // approximation
|
||||||
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
|
$css['table.sheet' . $sheetIndex . ' col.col' . $column]['width'] = '42pt';
|
||||||
}
|
}
|
||||||
@ -862,8 +860,8 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
public function generateHTMLFooter() {
|
public function generateHTMLFooter() {
|
||||||
// Construct HTML
|
// Construct HTML
|
||||||
$html = '';
|
$html = '';
|
||||||
$html .= ' </body>' . "\r\n";
|
$html .= ' </body>' . PHP_EOL;
|
||||||
$html .= '</html>' . "\r\n";
|
$html .= '</html>' . PHP_EOL;
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $html;
|
return $html;
|
||||||
@ -884,27 +882,28 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
|
|
||||||
if (!$this->_useInlineCss) {
|
if (!$this->_useInlineCss) {
|
||||||
$gridlines = $pSheet->getShowGridLines() ? ' gridlines' : '';
|
$gridlines = $pSheet->getShowGridLines() ? ' gridlines' : '';
|
||||||
$html .= ' <table border="0" cellpadding="0" cellspacing="0" id="sheet' . $sheetIndex . '" class="sheet' . $sheetIndex . $gridlines . '">' . "\r\n";
|
$html .= ' <table border="0" cellpadding="0" cellspacing="0" id="sheet' . $sheetIndex . '" class="sheet' . $sheetIndex . $gridlines . '">' . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$style = isset($this->_cssStyles['table']) ?
|
$style = isset($this->_cssStyles['table']) ?
|
||||||
$this->_assembleCSS($this->_cssStyles['table']) : '';
|
$this->_assembleCSS($this->_cssStyles['table']) : '';
|
||||||
|
|
||||||
if ($this->_isPdf && $pSheet->getShowGridLines()) {
|
if ($this->_isPdf && $pSheet->getShowGridLines()) {
|
||||||
$html .= ' <table border="1" cellpadding="0" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . "\r\n";
|
$html .= ' <table border="1" cellpadding="0" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$html .= ' <table border="0" cellpadding="0" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . "\r\n";
|
$html .= ' <table border="0" cellpadding="0" id="sheet' . $sheetIndex . '" cellspacing="0" style="' . $style . '">' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write <col> elements
|
// Write <col> elements
|
||||||
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
|
$highestColumnIndex = PHPExcel_Cell::columnIndexFromString($pSheet->getHighestColumn()) - 1;
|
||||||
for ($i = 0; $i <= $highestColumnIndex; ++$i) {
|
$i = -1;
|
||||||
|
while($i++ < $highestColumnIndex) {
|
||||||
if (!$this->_useInlineCss) {
|
if (!$this->_useInlineCss) {
|
||||||
$html .= ' <col class="col' . $i . '">' . "\r\n";
|
$html .= ' <col class="col' . $i . '">' . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ?
|
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) ?
|
||||||
$this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : '';
|
$this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' col.col' . $i]) : '';
|
||||||
$html .= ' <col style="' . $style . '">' . "\r\n";
|
$html .= ' <col style="' . $style . '">' . PHP_EOL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -920,7 +919,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
private function _generateTableFooter() {
|
private function _generateTableFooter() {
|
||||||
// Construct HTML
|
// Construct HTML
|
||||||
$html = '';
|
$html = '';
|
||||||
$html .= ' </table>' . "\r\n";
|
$html .= ' </table>' . PHP_EOL;
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $html;
|
return $html;
|
||||||
@ -962,12 +961,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
|
|
||||||
// Write row start
|
// Write row start
|
||||||
if (!$this->_useInlineCss) {
|
if (!$this->_useInlineCss) {
|
||||||
$html .= ' <tr class="row' . $pRow . '">' . "\r\n";
|
$html .= ' <tr class="row' . $pRow . '">' . PHP_EOL;
|
||||||
} else {
|
} else {
|
||||||
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow])
|
$style = isset($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow])
|
||||||
? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : '';
|
? $this->_assembleCSS($this->_cssStyles['table.sheet' . $sheetIndex . ' tr.row' . $pRow]) : '';
|
||||||
|
|
||||||
$html .= ' <tr style="' . $style . '">' . "\r\n";
|
$html .= ' <tr style="' . $style . '">' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write cells
|
// Write cells
|
||||||
@ -1096,7 +1095,9 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
// We must explicitly write the width of the <td> element because TCPDF
|
// We must explicitly write the width of the <td> element because TCPDF
|
||||||
// does not recognize e.g. <col style="width:42pt">
|
// does not recognize e.g. <col style="width:42pt">
|
||||||
$width = 0;
|
$width = 0;
|
||||||
for ($i = $colNum; $i < $colNum + $colSpan; ++$i) {
|
$i = $colNum - 1;
|
||||||
|
$e = $colNum + $colSpan - 1;
|
||||||
|
while($i++ < $e) {
|
||||||
if (isset($this->_columnWidths[$sheetIndex][$i])) {
|
if (isset($this->_columnWidths[$sheetIndex][$i])) {
|
||||||
$width += $this->_columnWidths[$sheetIndex][$i];
|
$width += $this->_columnWidths[$sheetIndex][$i];
|
||||||
}
|
}
|
||||||
@ -1128,7 +1129,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
$html .= $cellData;
|
$html .= $cellData;
|
||||||
|
|
||||||
// Column end
|
// Column end
|
||||||
$html .= '</td>' . "\r\n";
|
$html .= '</td>' . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next column
|
// Next column
|
||||||
@ -1136,7 +1137,7 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write row end
|
// Write row end
|
||||||
$html .= ' </tr>' . "\r\n";
|
$html .= ' </tr>' . PHP_EOL;
|
||||||
|
|
||||||
// Return
|
// Return
|
||||||
return $html;
|
return $html;
|
||||||
@ -1282,11 +1283,13 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
$lc = PHPExcel_Cell::columnIndexFromString($lc) - 1;
|
$lc = PHPExcel_Cell::columnIndexFromString($lc) - 1;
|
||||||
|
|
||||||
// loop through the individual cells in the individual merge
|
// loop through the individual cells in the individual merge
|
||||||
for ($r = $fr; $r <= $lr; ++$r) {
|
$r = $fr - 1;
|
||||||
|
while($r++ < $lr) {
|
||||||
// also, flag this row as a HTML row that is candidate to be omitted
|
// also, flag this row as a HTML row that is candidate to be omitted
|
||||||
$candidateSpannedRow[$r] = $r;
|
$candidateSpannedRow[$r] = $r;
|
||||||
|
|
||||||
for ($c = $fc; $c <= $lc; ++$c) {
|
$c = $fc - 1;
|
||||||
|
while($c++ < $lc) {
|
||||||
if ( !($c == $fc && $r == $fr) ) {
|
if ( !($c == $fc && $r == $fr) ) {
|
||||||
// not the upper-left cell (should not be written in HTML)
|
// not the upper-left cell (should not be written in HTML)
|
||||||
$this->_isSpannedCell[$sheetIndex][$r][$c] = array(
|
$this->_isSpannedCell[$sheetIndex][$r][$c] = array(
|
||||||
@ -1320,11 +1323,12 @@ class PHPExcel_Writer_HTML implements PHPExcel_Writer_IWriter {
|
|||||||
if ( isset($this->_isSpannedRow[$sheetIndex]) ) {
|
if ( isset($this->_isSpannedRow[$sheetIndex]) ) {
|
||||||
foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) {
|
foreach ($this->_isSpannedRow[$sheetIndex] as $rowIndex) {
|
||||||
$adjustedBaseCells = array();
|
$adjustedBaseCells = array();
|
||||||
for ($c = 0; $c < $countColumns; ++$c) {
|
$c = -1;
|
||||||
|
$e = $countColumns - 1;
|
||||||
|
while($c++ < $e) {
|
||||||
$baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
|
$baseCell = $this->_isSpannedCell[$sheetIndex][$rowIndex][$c]['baseCell'];
|
||||||
|
|
||||||
if ( !in_array($baseCell, $adjustedBaseCells) ) {
|
if ( !in_array($baseCell, $adjustedBaseCells) ) {
|
||||||
|
|
||||||
// subtract rowspan by 1
|
// subtract rowspan by 1
|
||||||
--$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
|
--$this->_isBaseCell[$sheetIndex][ $baseCell[0] ][ $baseCell[1] ]['rowspan'];
|
||||||
$adjustedBaseCells[] = $baseCell;
|
$adjustedBaseCells[] = $baseCell;
|
||||||
|
Loading…
Reference in New Issue
Block a user