-
Notifications
You must be signed in to change notification settings - Fork 530
word header footer set
zmworm edited this page Apr 29, 2026
·
52 revisions
Modify header and footer content and formatting.
Path: /header[N], /footer[N]
Set operates on the first paragraph of the header/footer. Paragraph-level properties are applied via the shared ApplyParagraphLevelProperty helper, and run-level formatting is applied to all runs in the container.
| Property | Accepted Values | Description |
|---|---|---|
text |
any text | Replace all runs with new text (preserves existing run formatting) |
font |
font name | Font family |
size |
14, 14pt, 10.5pt
|
Font size |
bold |
true/false
|
Bold |
italic |
true/false
|
Italic |
color |
#FF0000, FF0000, red, rgb(255,0,0)
|
Text color |
underline |
single, double, thick, dotted, dash, wave, etc. |
Underline style |
strike |
true/false
|
Strikethrough |
highlight |
yellow, green, cyan, magenta, blue, red, etc. |
Highlight color |
Run-level formatting is applied to every run in the header/footer and also sets the paragraph mark run properties so new text inherits the formatting.
These are delegated to the shared paragraph property handler:
| Property | Accepted Values | Description |
|---|---|---|
style |
style ID | Paragraph style (e.g., Header, Footer) |
alignment |
left, center, right, justify
|
Paragraph alignment (alias: align) |
firstLineIndent |
twips | First line indent |
leftIndent |
twips | Left indent (aliases: indentLeft, indent) |
rightIndent |
twips | Right indent (alias: indentRight) |
hangingIndent |
twips | Hanging indent (alias: hanging) |
spaceBefore |
12pt, 0.5cm, 0.5in, or bare twips |
Space before paragraph |
spaceAfter |
12pt, 0.5cm, 0.5in, or bare twips |
Space after paragraph |
lineSpacing |
1.5x, 150%, 18pt, or bare twips |
Line spacing |
keepNext |
true/false
|
Keep with next paragraph |
keepLines |
true/false
|
Keep lines together |
pageBreakBefore |
true/false
|
Page break before |
widowControl |
true/false
|
Widow/orphan control |
shading |
fill or val;fill or val;fill;color
|
Paragraph background (alias: shd) |
pbdr.* |
style;size;color;space |
Paragraph borders (.top, .bottom, .left, .right, .between, .bar, .all) |
-
setmodifies the first paragraph. To modify other paragraphs, target them directly:/header[1]/p[2]. - Setting
textreplaces all runs in the first paragraph but preserves the run properties from the first existing run. - The
typeproperty (default/first/even) is set at add time via the section reference and cannot be changed withset. To change a header's type, remove it and add a new one.
# Update header text and center it
officecli set report.docx /header[1] --prop text="Updated Header" --prop alignment=center
# Style a footer with small gray italic text
officecli set report.docx /footer[1] --prop size=8 --prop color=999999 --prop italic=true
# Apply bold formatting to all runs in a header
officecli set report.docx /header[1] --prop bold=true
# Change paragraph style
officecli set report.docx /header[1] --prop style=Header
# Set paragraph spacing in header
officecli set report.docx /header[1] --prop spaceAfter=6pt
# Modify a specific paragraph inside a header
officecli set report.docx /header[1]/p[2] --prop text="Second line" --prop alignment=rightBased on OfficeCLI v1.0.64