Report appearance#
This page is about how a Word report looks: the tables, and the headings above them. Everything here is written into the document’s styles, so it survives editing — a row or a section added in Word afterwards looks like the ones mento wrote.
Table style#
The tables in a Word report are banded grey with a bold header, ruled above, below and
under the header row and nowhere else. set_table_style replaces that look for the rest
of the session, so it is written once, before the documents are produced:
import mento
from mento import TableStyle
mento.set_table_style(TableStyle(band_fill="F4F7FB", header_fill="2C6DC4",
header_color="FFFFFF"))
Every Word document produced afterwards uses it:
from mento import Concrete_ACI_318_19, SteelBar, RectangularBeam, Node, Forces
from mento import MPa, cm, mm, kN, kNm
concrete = Concrete_ACI_318_19(name="H25", f_c=25 * MPa)
steel = SteelBar(name="ADN 420", f_y=420 * MPa)
beam = RectangularBeam(
label="101", concrete=concrete, steel_bar=steel,
width=20 * cm, height=60 * cm, c_c=25 * mm,
)
node = Node(section=beam, forces=[Forces(label="C1", V_z=80 * kN, M_y=100 * kNm)])
node.design()
node.shear_results_detailed_doc() # a Word document in the new style
mento.get_table_style() returns the style in force. One document can depart from it
without changing the setting, by building its own DocumentBuilder:
from mento import DocumentBuilder, TableStyle
builder = DocumentBuilder(title="Report", table_style=TableStyle(band_fill=""))
What can be set#
Field |
Default |
Meaning |
|---|---|---|
|
|
The style’s name in Word’s gallery. |
|
|
Fill of the banded rows. Empty for no banding. |
|
|
How many rows a band spans. |
|
|
Fill of the header row. Empty for no fill. |
|
|
Text colour of the header row. Empty to use the body’s. |
|
|
Whether the header row is bold. |
|
|
Text colour of the table. |
|
|
Colour of every rule the style draws. |
|
|
Rule above the header. |
|
|
Rule between the header and the first data row. |
|
|
Rule closing the table. |
|
|
Rule between data rows. |
|
|
Rule between columns. |
|
|
Air above and below the text in a cell. |
Colours and thicknesses#
A colour is six hexadecimal digits with no #. Word does not object to "#F2F2F2";
it discards the fill and renders the table without it, so TableStyle raises
ValueError instead:
TableStyle(band_fill="#F2F2F2") # ValueError
TableStyle(band_fill="F2F2F2") # a light grey
An empty colour means the field is left unset, and whatever is behind it shows through:
header_fill="" is a header with no fill, text_color="" takes the document’s text
colour.
A thickness is given in points. Word draws no rule thinner than 0.25 pt and none
thicker than 12 pt, and anything outside that range is drawn at the nearest end of it. A
thickness of exactly 0 is not a hairline but the absence of a rule, which is why the
default table has no lines between its rows: the banding already separates them.
cell_padding_pt is in points too. It is charged once per row, so it is the field that
decides how tall a long table is: a detailed annex is forty rows of it, and the default is
set so those annexes close on one page. Word’s own comfortable padding is 1.4 pt, and a
report that has room for it can ask:
mento.set_table_style(TableStyle(cell_padding_pt=1.4))
One page#
flexure_results_detailed_doc() and shear_results_detailed_doc() are one-page
annexes, and the default settings keep them there: the document text is 8.5 pt, paragraphs
carry no trailing gap and no extra leading, and the space between blocks is put there by
the builder rather than trailing every line.
They stay one page whatever is checked. Each report is built from the governing combination rather than from every one of them, so its tables have a fixed shape — 42 rows for a flexure report, 40 for a shear one — and the beam, the design code and the number of load combinations change the numbers in them rather than their number of rows.
Why a style and not formatting#
The look is written into the document once, as a table style, and every table points at it. Two things follow from that. A table keeps its look when it is edited — a row added in Word is banded, because the banding is a rule in the document rather than a fill painted on the rows that existed when it was written. And a report of forty tables carries one definition, so the choice can be changed in one place, including by hand in Word.
The pass/fail column of a summary is the exception: green and red are applied to those cells directly, which outranks the style, so the verdict keeps its colour whatever the table style says.
Headings#
The report title is a Heading 1, the sections under it are Heading 2, and both are
numbered and coloured by the document’s styles:
1 Beam 101 flexure check
1.1 Section Data
1.2 Limit checks
1.3 Flexural Capacity Top
1.4 Flexural Capacity Bottom
The numbers are Word’s own, not text mento wrote: the styles are attached to a multilevel list defined in the document, so a section moved, deleted or inserted in Word renumbers the rest.
The headings are set in the document’s font, which needs saying because Word’s built-in heading styles name the theme font beside the literal one and resolve the theme first — the same trap as the theme fill in a table style. It shows up in a place nobody looks: a heading’s number is drawn in the paragraph mark’s font, so a report whose heading text was set run by run still came out with Calibri numbers in front of Lato titles.
The Heading 1 is #0A3E81 and everything else on the page — the sub-headings, the
running text and the tables — is #323232, so the one colour that appears reads as a
heading rather than as decoration. The green and red of a verdict column are the
exception, and are applied to those cells directly.