Correct column style even when using rowspan

Closes #1249
This commit is contained in:
coolhub 2019-11-21 18:04:55 +08:00 committed by Adrien Crivelli
parent cc92c6648e
commit 86fa5424a6
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
3 changed files with 25 additions and 3 deletions

View File

@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org).
### Fixed ### Fixed
- FLOOR() function accept negative number and negative significance [#1245](https://github.com/PHPOffice/PhpSpreadsheet/pull/1245) - FLOOR() function accept negative number and negative significance [#1245](https://github.com/PHPOffice/PhpSpreadsheet/pull/1245)
- Correct column style even when using rowspan [#1249](https://github.com/PHPOffice/PhpSpreadsheet/pull/1249)
## [1.10.0] - 2019-11-18 ## [1.10.0] - 2019-11-18

View File

@ -490,13 +490,13 @@ class Html extends BaseReader
case 'td': case 'td':
$this->processDomElement($child, $sheet, $row, $column, $cellContent); $this->processDomElement($child, $sheet, $row, $column, $cellContent);
// apply inline style
$this->applyInlineStyle($sheet, $row, $column, $attributeArray);
while (isset($this->rowspan[$column . $row])) { while (isset($this->rowspan[$column . $row])) {
++$column; ++$column;
} }
// apply inline style
$this->applyInlineStyle($sheet, $row, $column, $attributeArray);
$this->flushCell($sheet, $column, $row, $cellContent); $this->flushCell($sheet, $column, $row, $cellContent);
if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) { if (isset($attributeArray['rowspan'], $attributeArray['colspan'])) {

View File

@ -403,4 +403,25 @@ class HtmlTest extends TestCase
$actual = $spreadsheet->getActiveSheet()->getMergeCells(); $actual = $spreadsheet->getActiveSheet()->getMergeCells();
self::assertSame(['A2:C2' => 'A2:C2'], $actual); self::assertSame(['A2:C2' => 'A2:C2'], $actual);
} }
public function testTextIndentUseRowspan()
{
$html = '<table>
<tr>
<td>1</td>
<td rowspan="2" style="vertical-align: center;">Center Align</td>
<td>Row</td>
</tr>
<tr>
<td>2</td>
<td style="text-indent:10px">Text Indent</td>
</tr>
</table>';
$filename = $this->createHtml($html);
$spreadsheet = $this->loadHtmlIntoSpreadsheet($filename);
$firstSheet = $spreadsheet->getSheet(0);
$style = $firstSheet->getCell('C2')->getStyle();
self::assertEquals(10, $style->getAlignment()->getIndent());
unlink($filename);
}
} }