Merge pull request #4449 from oleibman/issue4448

XML Reader Recognize Indents
This commit is contained in:
oleibman
2025-04-23 05:45:32 +00:00
committed by GitHub
3 changed files with 106 additions and 0 deletions
@@ -49,6 +49,10 @@ class Alignment extends StyleBase
case 'Rotate':
$style['alignment']['textRotation'] = $styleAttributeValue;
break;
case 'Indent':
$style['alignment']['indent'] = $styleAttributeValue;
break;
}
}
@@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xml;
use PhpOffice\PhpSpreadsheet\Reader\Xml;
use PHPUnit\Framework\TestCase;
class Issue4448Test extends TestCase
{
private static string $testbook = 'tests/data/Reader/Xml/issue.4448.xml';
public function testIndent(): void
{
$reader = new Xml();
$spreadsheet = $reader->load(self::$testbook);
$sheet = $spreadsheet->getActiveSheet();
self::assertSame(
5,
$sheet->getStyle('A2')
->getAlignment()
->getIndent()
);
self::assertSame(
0,
$sheet->getStyle('A1')
->getAlignment()
->getIndent()
);
$spreadsheet->disconnectWorksheets();
}
}
+69
View File
@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<?mso-application progid="Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
xmlns:html="http://www.w3.org/TR/REC-html40">
<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
<Author>owen</Author>
<LastAuthor>owen</LastAuthor>
<Created>2025-04-20T15:09:21Z</Created>
<Version>16.00</Version>
</DocumentProperties>
<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
<AllowPNG/>
</OfficeDocumentSettings>
<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
<WindowHeight>6630</WindowHeight>
<WindowWidth>19200</WindowWidth>
<WindowTopX>32767</WindowTopX>
<WindowTopY>32767</WindowTopY>
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="Default" ss:Name="Normal">
<Alignment ss:Vertical="Bottom"/>
<Borders/>
<Font ss:FontName="Aptos Narrow" x:Family="Swiss" ss:Size="11"
ss:Color="#000000"/>
<Interior/>
<NumberFormat/>
<Protection/>
</Style>
<Style ss:ID="s63">
<Alignment ss:Horizontal="Left" ss:Vertical="Bottom" ss:Indent="5"/>
</Style>
</Styles>
<Worksheet ss:Name="Sheet1">
<Table ss:ExpandedColumnCount="1" ss:ExpandedRowCount="3" x:FullColumns="1"
x:FullRows="1" ss:DefaultRowHeight="14.5">
<Row>
<Cell><Data ss:Type="String">a</Data></Cell>
</Row>
<Row>
<Cell ss:StyleID="s63"><Data ss:Type="String">b</Data></Cell>
</Row>
<Row>
<Cell><Data ss:Type="String">c</Data></Cell>
</Row>
</Table>
<WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
<PageSetup>
<Header x:Margin="0.3"/>
<Footer x:Margin="0.3"/>
<PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
</PageSetup>
<Selected/>
<Panes>
<Pane>
<Number>3</Number>
<ActiveRow>1</ActiveRow>
</Pane>
</Panes>
<ProtectObjects>False</ProtectObjects>
<ProtectScenarios>False</ProtectScenarios>
</WorksheetOptions>
</Worksheet>
</Workbook>