Skip to content

Commit

Permalink
Improving Coverage for Excel2003 XML Reader (#1557)
Browse files Browse the repository at this point in the history
* Improving Coverage for Excel2003 XML Reader

Reader/Xml is now 100% covered.

File templates/Excel2003XMLTest.xml, used in some tests, is *not*
readable by a current version of Excel. I have substituted a new file
excel2003.xml to be used in its place. I have not deleted the original
in case someone in future (possibly me) wants to see what it needs to
make it usable.

There are minimal code changes.
- Unused protected functions pixel2WidthUnits and widthUnits2Pixel
  are deleted.
- One regex looking to convert hex characters is changed from a-z to a-f,
  and made case insensitive.
- No calculation performed for "error" cell (previously calculation
  was attempted and threw exception).
- Empty relative row/cell is now handled correctly.
- Style applied to empty cell when appropriate.
- Support added for textRotation.
- Support added for border styles.
- Support added for diagonal borders.
- Support added for superscript and subscript.
- Support added for fill patterns.

In theory, encodings other than UTF-8 were supported.
In fact, I was unable to get SecurityScanner to pass *any* xml which is
not UTF-8. Eliminating the assumption that strings might not be UTF-8
allowed much of the code to be greatly simplified.
After that, I added some code that would permit the use of
some ASCII-compatible encodings (there is a test of ISO-8859-1).
It would be more difficult to handle other encodings (such as UTF-16).
I am not convinced that even the ISO-8859 effort is worth it,
but am willing to investigate either expanding or eliminating
non-UTF8 support.

I added a number of tests, creating an Xml directory, and moving
XmlTest to that directory.

Pull Request had problems reading old invalid sample in the code
coverage phase, not in any of the other test phases, and not in
the code coverage phase on my local machine.
As it turns out, aside from being invalid, the sample
is much larger than any of the other samples. Tests have been
adjusted accordingly.

* Smaller Test File

Should eliminate need to avoid test during xml coverage.

* Break Up Style Test into Multiple Tests

Per suggestion from Mark Baker.

* Integrate AddressHelper Change

The introduction of AddressHelper introduced a conflict which needed to
be resolved. I wanted to test it locally before resolving. This required
me to add (unchanged) AddressHelper to my local copy. I hope this is
an okay manner of resolving the conflict.

* Weird Travis Error

XmlOddTest works just fine on my local machine, but Travis failed it.
Even worse, the lines which Travis flags don't even make any sense
(one was the empty line between two methods!).
This test is not essential to the rest of the change. I am removing
it from the package, and will attempt to re-add it when I have a chance
to sync up my fork with the main project.
  • Loading branch information
oleibman authored Oct 11, 2020
1 parent 7545c41 commit 1741766
Show file tree
Hide file tree
Showing 13 changed files with 1,645 additions and 128 deletions.
2 changes: 1 addition & 1 deletion samples/Basic/20_Read_Excel2003XML.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

require __DIR__ . '/../Header.php';

$filename = __DIR__ . '/../templates/Excel2003XMLTest.xml';
$filename = __DIR__ . '/../templates/excel2003.xml';
$callStartTime = microtime(true);
$spreadsheet = IOFactory::load($filename);
$helper->logRead('Xml', $filename, $callStartTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
<ProtectStructure>False</ProtectStructure>
<ProtectWindows>False</ProtectWindows>
</ExcelWorkbook>
<Styles>
<Style ss:ID="ce9">
<Alignment ss:Vertical="Bottom" ss:Rotate="0"/>
<Borders/>
<Font ss:Color="#000000" ss:FontName="Arial1" ss:Size="11"/>
<NumberFormat ss:Format="Short Date"/>
</Style>
<Style ss:ID="ce32">
<Alignment ss:Horizontal="Center" ss:Vertical="Center" ss:WrapText="1" ss:Rotate="0"/>
<Borders/>
<Font ss:Color="#000000" ss:FontName="Calibri" ss:Size="11"/>
</Style>
</Styles>
<ss:Worksheet ss:Name="Sample Data">
<Table>
<Column ss:Width="96.4913"/>
Expand All @@ -28,7 +41,7 @@
<Column ss:Span="6" ss:Width="48.3874"/>
<Column ss:Index="12" ss:Width="50.2583"/>
<Column ss:Span="1011" ss:Width="48.3874"/>
<Row ss:AutoFitHeight="0" ss:Height="14.9953">
<Row ss:Index="8" ss:AutoFitHeight="0" ss:Height="14.9953">
<Cell>
<ss:Data xmlns="http://www.w3.org/TR/REC-html40" ss:Type="String">Test String 1</ss:Data>
<Comment>
Expand All @@ -38,7 +51,16 @@
</Comment>
</Cell>
<Cell>
<Data ss:Type="Number">1</Data>
<Data ss:StyleID="ce32" ss:Type="Number">1</Data>
</Cell>
<Cell ss:Formula="of:=12/1">
<Data ss:Type="Number">12</Data>
</Cell>
<Cell ss:Formula="of:=[.C8]-[.B8]">
<Data ss:Type="Number">11</Data>
</Cell>
<Cell ss:StyleID="ce9">
<Data ss:Type="DateTime">1960-12-19T00:00:00.000</Data>
</Cell>
</Row>
</Table>
Expand Down
Loading

0 comments on commit 1741766

Please sign in to comment.