FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Bonsai: draw the cell borders a schedule's spreadsheet declares by carlopav · Pull Request #9350 · IfcOpenShell/IfcOpenShell · GitHub

Bonsai: draw the cell borders a schedule's spreadsheet declares - #9350

Closed
carlopav wants to merge 1 commit into
IfcOpenShell:v0.8.0from
carlopav:bonsai/schedule-cell-borders
Closed

Bonsai: draw the cell borders a schedule's spreadsheet declares#9350
carlopav wants to merge 1 commit into
IfcOpenShell:v0.8.0from
carlopav:bonsai/schedule-cell-borders

Conversation

carlopav commented Aug 23, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

schedule_ods already collects every cell style attribute from the spreadsheet — background, font size, weight, style, color, wrap — and uses them. Borders are collected too, and discarded: every cell is drawn as a rectangle carrying one hardcoded class_="border" whose stroke comes from the stylesheet. schedule_xlsx does the same from openpyxl. A thick outline with thin inner rules, the usual look of an architectural schedule, cannot reach the drawing no matter what is set in LibreOffice or Excel.

What changed

The inline rectangle in both branches becomes draw_cell(), which takes a background color and the borders already resolved, so it is independent of the source format. Each branch translates its own:

  • get_cell_borders() / parse_border() read .ods style attributes;
  • get_xlsx_cell_borders() / parse_xlsx_border() read openpyxl Side objects.

A cell that declares no border keeps the .border class and draws exactly as before. One that declares them gets a line per side, which a single rectangle stroke cannot express.

Width, style and color are read in any order, per the CSS border shorthand grammar (<width> || <style> || <color>), rather than assuming the order LibreOffice happens to emit. dotted and dashed become a dash pattern scaled by the line width; double and the relief styles draw plain.

XLSX_BORDERS converts Excel's fourteen named weights into widths and dash patterns. Excel names a weight instead of measuring one, so that table is a choice rather than a reading of the file, and is commented as such.

One deliberate behaviour change

A cell that declares border: none now draws no line, where before it took the stylesheet's. This is intentional and is half the point of the change: a sheet that says a side has no border should not be given one.

Cells that declare nothing about borders are unaffected — that is the compatibility guarantee, and it covers every schedule IfcCsv writes, since it emits no cell styles at all.

Left as it is

Adjacent cells each stroke the edge they share, so where two neighbours declare it differently the later one wins. The rectangles overlapped the same way before, with the same stroke on both sides. Spreadsheet applications resolve such conflicts by precedence, which this does not attempt.

Testing

src/bonsai/test/bim/module/drawing/test_scheduler.py — 20 tests over both translators and the drawing: the untouched-cell guarantee, the border: none change, per-side overrides of the shorthand, token order, dash patterns, and the openpyxl side. One trap they pin down: asked for the ARGB of a theme color, openpyxl returns its own complaint as a string instead of raising, so the length of the value is what distinguishes a real ARGB from it.

black and ruff clean on both files.

Notes

AI disclosure

Per AGENTS.md: this contribution was written with the assistance of an AI coding tool, in whole — both the change to scheduler.py and the new test file, which carries the required header comment.

schedule_ods already collected every cell style attribute from the sheet,
borders included, then drew every cell with one hardcoded `.border` class,
and schedule_xlsx did the same from openpyxl. A thick outline with thin
inner rules — the normal look of an architectural schedule — could not
reach the drawing.

The inline rectangle in both branches becomes draw_cell(), which takes a
background colour and the borders already resolved, so it knows nothing of
the format it serves. Each branch translates its own: get_cell_borders
reads ODF style attributes, get_xlsx_cell_borders reads openpyxl Sides. A
cell that rules no side keeps the `.border` class and draws as before; one
that rules them gets a line per side, since a rectangle carries a single
stroke and a spreadsheet routinely asks for four different ones.

Width, style and colour are read in any order, per the CSS2 shorthand
grammar. Dotted and dashed become a dash pattern scaled by the line's own
width; double and the relief styles draw plain. Excel names a weight
rather than measuring one, so XLSX_BORDERS converts its fourteen names
into widths and patterns — that table is a choice, not a reading, and is
commented as such.

A cell declaring `border: none` now draws no line where it used to take
the stylesheet's. That is deliberate: turning a rule off from the
spreadsheet is half of what this makes possible, and a sheet saying a side
has no border should not be given one. Cells declaring nothing are
untouched.

Left as it is: adjacent cells each stroke the edge they share, so where
neighbours rule it differently the later one wins — the previous
rectangles overlapped the same way.

Generated with the assistance of an AI coding tool.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
carlopav closed this Aug 23, 2026
carlopav changed the title Bonsai: a schedule draws the cell borders its spreadsheet declares Bonsai: draw the cell borders a schedule's spreadsheet declares Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #9351: a force-push left this pull request pointing at an orphaned commit, and it could not be reopened. #9351 carries the same change from the same branch, with the review comments already applied.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL