Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML-Readers: Border Specification #4000

Closed
SlowFox71 opened this issue Apr 25, 2024 · 0 comments · Fixed by #4003
Closed

XML-Readers: Border Specification #4000

SlowFox71 opened this issue Apr 25, 2024 · 0 comments · Fixed by #4003

Comments

@SlowFox71
Copy link

This is:

- [x ] a bug report

What is the expected behavior?

Borders of files read with PhpSpreadsheet render the same as in Excel.

What is the current behavior?

Borders are ignored.

What are the steps to reproduce?

Load the attached file with XML-Reader and save it as XLSX vs. open it directly with Excel.

What features do you think are causing the issue

  • [ x] Reader

Does an issue affect all spreadsheet file formats? If not, which formats are affected?

Only XML Reader is affected.

Which versions of PhpSpreadsheet and PHP are affected?

Tested with PhpSpreadsheet 2.0.0 and PHP 8.2.18.

I am finally able to use PHP8+ and thus to investigate the updated XML reader (as opposed to my old, self-patched version I used last year). Here I found 2 problems with borders:

a) the ss:Styles section is not interpreted because of searching the global namespace, while the documentation defines 'ss':

https://learn.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa140066(v=office.10)?redirectedfrom=MSDN#ssstyles-tag

b) Weight="0" is rendered to LineStyle="None" while the documentation defines it as hairline:

https://learn.microsoft.com/en-us/previous-versions/office/developer/office-xp/aa140066(v=office.10)?redirectedfrom=MSDN#ssborder-tag

As far as I can see Excel converts this to "hair" when saving the attached file as an XLSX; I'd be happy with "thin" as well, but "none" should not be used.

border_xml.txt

oleibman added a commit to oleibman/PhpSpreadsheet that referenced this issue Apr 27, 2024
Fix PHPOffice#3999. Fix PHPOffice#4000. Fix PHPOffice#4002. Several bug reports and feature requests for Xml Reader arrived practically simultaneously. They are all small and hit the same code modules, so I have bundled them together in one PR.
- `loadSpreadsheetFromString` might try to open a file with a falsy name (like '0'), which results in an exception with a misleading message (or a completely unexpected result if a file with that name exists). Code will still throw an exception, but the message will no longer be misleading, and no file I/O will be attempted.
- function `trySimpleXmlLoadString` is deprecated. It should never have been implemented with public visibility, and the fact that it was made the fix above a little more difficult than it would otherwise have been. It is replaced with a private equivalent.
- Style reader function `parseStyles` will now use a better namespace-aware method of reading its Xml data. Peculiarly, the Xml for the Style elements can either include or not a namespace prefix. This is probably because the global namespace and the styles namespace are the same. The existing prefix-based code does not recognize their equivalence, but the new namespace-based code does. Xml Reader continues to use prefix-based code in several other places.
- Border line styles with Weight omitted or equal to 0 have been treated as no border, but they should be treated as 'hair' thickness.
- Support for Zoom is added to Xml Reader.
- In support of the above, new properties (and getters and setters) zoomScalePageLayoutView and zoomScaleSheetLayoutView are added to Worksheet/SheetView. (As far as I can tell, Excel does not support Sheet Layout View for Xml spreadsheets).
- Support is added for those new properties in Xlsx Reader and Writer.
- Xls Reader and Writer seem to work okay without changes. There is one test where Xls shows a different value for one of the properties than Xml or Xlsx, but the spreadsheet looks okay and I don't see any practical consequences of the difference.
- PageBreak support is added to Xml Reader.
- Code for writing out Column Page Breaks in Xlsx Writer was wrong (and, unsurprisingly, untested). A one-line change fixes it, and tests are added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant