diff --git a/src/PhpSpreadsheet/Reader/Html.php b/src/PhpSpreadsheet/Reader/Html.php index 1a0ef5d34d..b7faac878c 100644 --- a/src/PhpSpreadsheet/Reader/Html.php +++ b/src/PhpSpreadsheet/Reader/Html.php @@ -469,7 +469,7 @@ private function processDomElementTable(Worksheet $sheet, int &$row, string &$co if ($child->nodeName === 'table') { $this->flushCell($sheet, $column, $row, $cellContent); $column = $this->setTableStartColumn($column); - if ($this->tableLevel > 1) { + if ($this->tableLevel > 1 && $row > 1) { --$row; } $this->processDomElement($child, $sheet, $row, $column, $cellContent); @@ -878,14 +878,14 @@ private function applyInlineStyle(&$sheet, $row, $column, $attributeArray): void case 'width': $sheet->getColumnDimension($column)->setWidth( - (float) str_replace('px', '', $styleValue) + (float) str_replace(['px', 'pt'], '', $styleValue) ); break; case 'height': $sheet->getRowDimension($row)->setRowHeight( - (float) str_replace('px', '', $styleValue) + (float) str_replace(['px', 'pt'], '', $styleValue) ); break; @@ -1009,7 +1009,15 @@ private function setBorderStyle(Style $cellStyle, $styleValue, $type): void $borderStyle = Border::BORDER_NONE; $color = null; } else { - [, $borderStyle, $color] = explode(' ', $styleValue); + $borderArray = explode(' ', $styleValue); + $borderCount = count($borderArray); + if ($borderCount >= 3) { + $borderStyle = $borderArray[1]; + $color = $borderArray[2]; + } else { + $borderStyle = $borderArray[0]; + $color = $borderArray[1] ?? null; + } } $cellStyle->applyFromArray([ diff --git a/tests/PhpSpreadsheetTests/Reader/Html/Issue2029Test.php b/tests/PhpSpreadsheetTests/Reader/Html/Issue2029Test.php new file mode 100644 index 0000000000..08cdbc257f --- /dev/null +++ b/tests/PhpSpreadsheetTests/Reader/Html/Issue2029Test.php @@ -0,0 +1,115 @@ + + + + + Declaracion en Linea + + + + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + +
CUIT:
Período
Secuencia:
Contribuyente:
+
+
+ + + + + + + + + + + + + + + + + + + + + +
+ CUIL + + Apellido y Nombre + + Obra Social + + Corresponde Reducción? +
+ 12345678901 + + EMILIANO ZAPATA SALAZAR + + 101208 + + Yes +
+ 23456789012 + + FRANCISCO PANCHO VILLA + + 101208 + + No +
+ + + +EOF; + $reader = new Html(); + $spreadsheet = $reader->loadFromString($content); + $sheet = $spreadsheet->getActiveSheet(); + self::assertSame('CUIT:', $sheet->getCell('A1')->getValue()); + self::assertSame('30-53914190-9', $sheet->getCell('B1')->getValue()); + self::assertSame('Contribuyente:', $sheet->getCell('A4')->getValue()); + self::assertSame('Apellido y Nombre', $sheet->getCell('B9')->getValue()); + self::assertEquals('101208', $sheet->getCell('C10')->getValue()); + self::assertEquals('Yes', $sheet->getCell('D10')->getValue()); + self::assertEquals('23456789012', $sheet->getCell('A11')->getValue()); + self::assertEquals('No', $sheet->getCell('D11')->getValue()); + } +}