Fix row visibility in XLS Writer (#2058)
* Fix reversed visibility in Xls Writer
This commit is contained in:
parent
346bad1b1d
commit
2b268c8dd9
|
|
@ -1220,13 +1220,13 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 1em;">Merged Cells</td>
|
<td style="padding-left: 1em;">Merged Cells</td>
|
||||||
<td></td>
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td style="text-align: center; color: green;">✔</td>
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td style="text-align: center; color: green;">✔</td>
|
||||||
|
<td>N/A</td>
|
||||||
|
<td>N/A</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,9 @@ class Gnumeric extends BaseReader
|
||||||
$commentAttributes = $comment->attributes();
|
$commentAttributes = $comment->attributes();
|
||||||
// Only comment objects are handled at the moment
|
// Only comment objects are handled at the moment
|
||||||
if ($commentAttributes->Text) {
|
if ($commentAttributes->Text) {
|
||||||
$this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)->setAuthor((string) $commentAttributes->Author)->setText($this->parseRichText((string) $commentAttributes->Text));
|
$this->spreadsheet->getActiveSheet()->getComment((string) $commentAttributes->ObjectBound)
|
||||||
|
->setAuthor((string) $commentAttributes->Author)
|
||||||
|
->setText($this->parseRichText((string) $commentAttributes->Text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -390,7 +390,13 @@ class Worksheet extends BIFFwriter
|
||||||
// Row dimensions
|
// Row dimensions
|
||||||
foreach ($phpSheet->getRowDimensions() as $rowDimension) {
|
foreach ($phpSheet->getRowDimensions() as $rowDimension) {
|
||||||
$xfIndex = $rowDimension->getXfIndex() + 15; // there are 15 cellXfs
|
$xfIndex = $rowDimension->getXfIndex() + 15; // there are 15 cellXfs
|
||||||
$this->writeRow($rowDimension->getRowIndex() - 1, (int) $rowDimension->getRowHeight(), $xfIndex, $rowDimension->getVisible(), $rowDimension->getOutlineLevel());
|
$this->writeRow(
|
||||||
|
$rowDimension->getRowIndex() - 1,
|
||||||
|
(int) $rowDimension->getRowHeight(),
|
||||||
|
$xfIndex,
|
||||||
|
!$rowDimension->getVisible(),
|
||||||
|
$rowDimension->getOutlineLevel()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write Cells
|
// Write Cells
|
||||||
|
|
@ -1181,7 +1187,7 @@ class Worksheet extends BIFFwriter
|
||||||
// collapsed. The zero height flag, 0x20, is used to collapse a row.
|
// collapsed. The zero height flag, 0x20, is used to collapse a row.
|
||||||
|
|
||||||
$grbit |= $level;
|
$grbit |= $level;
|
||||||
if ($hidden) {
|
if ($hidden === true) {
|
||||||
$grbit |= 0x0030;
|
$grbit |= 0x0030;
|
||||||
}
|
}
|
||||||
if ($height !== null) {
|
if ($height !== null) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PhpOffice\PhpSpreadsheetTests\Writer\Xls;
|
||||||
|
|
||||||
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
||||||
|
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
|
||||||
|
|
||||||
|
class RowVisibilityTest extends AbstractFunctional
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider dataProviderReoVisibility
|
||||||
|
*/
|
||||||
|
public function testRowVisibility(array $visibleRows): void
|
||||||
|
{
|
||||||
|
$spreadsheet = new Spreadsheet();
|
||||||
|
$worksheet = $spreadsheet->getActiveSheet();
|
||||||
|
foreach ($visibleRows as $row => $visibility) {
|
||||||
|
$worksheet->setCellValue("A{$row}", $row);
|
||||||
|
$worksheet->getRowDimension($row)->setVisible($visibility);
|
||||||
|
}
|
||||||
|
|
||||||
|
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xls');
|
||||||
|
$reloadedWorksheet = $reloadedSpreadsheet->getActiveSheet();
|
||||||
|
foreach ($visibleRows as $row => $visibility) {
|
||||||
|
self::assertSame($visibility, $reloadedWorksheet->getRowDimension($row)->getVisible());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function dataProviderReoVisibility(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
[1 => true, 2 => false, 3 => false, 4 => true, 5 => true, 6 => false],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue