-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix for Issue 2029 (Invalid Cell Coordinate A-1) #2032
Conversation
Fix for PHPOffice#2021. When Html Reader encounters an embedded table, it tries to shift it up a row. It obviously should not attempt to shift it above row 1. @danmodini reported the problem, and suggests the correct solution. This PR implements that and adds a test case.
Scrutinizer.
Performing some additional testing, I found that Html Reader cannot handle inline column width or row height set in points rather than pixels (and HTML writer with useInlineCss generates these values in points). It also doesn't handle border style when the border width (which it ignores) is omitted. Fixed and added tests.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have half of a helper class that covers a wide range of the UoM that can be applied in html styles, with conversion factors for import to Spreadsheet styles... but this will work well enough for the moment... it's the relative units that are a real annoyance, because we can't adjudge 50%
accurately, as we don't know 50%
of what? I'll do that as a separate PR at some point though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be really helpful, especially because Excel widths and heights aren't well documented. They aren't pixels, or points, or twips, or ... I know the default column width in Excel units and in pixels, but I haven't had time to establish whether there is a linear relationship between them. The Html writer and reader probably make things too wide or too narrow because of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't really mean non-linear above - it is linear, but it depends on the font. Which may be too sophisticated to try to emulate (as with your 50% comment). But I think it translates better to expressing the unit as ems rather than points or pixels.
Fix for #2029. When Html Reader encounters an embedded table, it tries to shift it up a row. It obviously should not attempt to shift it above row 1. @danmodini reported the problem, and suggests the correct solution. This PR implements that and adds a test case.
This is:
Checklist:
Why this change is needed?