-
Notifications
You must be signed in to change notification settings - Fork 349
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
The order of setting a border can corrupt the style. #304
Comments
Thank you for reporting this, as it doesn't matter in the slightest to OpenXLSX, this will be an easy fix - I'll just add some additional sorting logic for these elements of XLStyles. Will report here when it's patched. Please feel welcome to open new issues for anything similar that you find. |
Okay, this was not quite as trivial as I thought, mostly because of the logic of how to sort against a predefined list of tag names, and how to respect (potential) whitespace nodes in the XML. |
closing as resolved - will introduce ordered XML inserts on a case by case basis when issues arise for other elements of the OOXML. |
It seems excel expects the border to be in the order left, right, top, bottom, diagonal in the styles.xml file. If it's not in this order then excel will give an error saying the style is corrupted. The order of the styles in OpenXLSX is determined by the order they are set in code. So if the Top, Bottom are set then the Right is set, the file cannot be opened in excel.
Works
auto leftBorder = borders.create(); borders[leftBorder].setOutline(true); borders[leftBorder].setLeft(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000")); borders[leftBorder].setTop(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000")); borders[leftBorder].setBottom(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000"));
Corrupts Style
auto leftBorder = borders.create(); borders[leftBorder].setOutline(true); borders[leftBorder].setTop(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000")); borders[leftBorder].setBottom(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000")); borders[leftBorder].setLeft(OpenXLSX::XLLineStyleThin, OpenXLSX::XLColor("ff000000"));
The text was updated successfully, but these errors were encountered: