#427·OfficeCLI

[feat][docx] One-shot exact table clone: match existing style incl. CJK fonts and asymmetric sz/szCs

Author: leeeezxCreated Sep 23, 2026Updated Sep 23, 2026

Use case

I had a .docx report where one table under "domestic/foreign vendors" was a screenshot image, while the rest of the document used real Table Grid tables. I wanted to replace that single image paragraph with a real 21x2 table that looks exactly like its neighbors.

Existing tables in the file look like this at the XML level:

  • tblStyle custom Table Grid (w:val="af0"), tblW=8220dxa, layout=fixed, tblLook=04A0
  • header cell: jc=center, rFonts eastAsia="黑体" cs="Times New Roman", b, color=000000, sz=21 + szCs=24
  • body cell: rFonts cs="Times New Roman" (eastAsia inherited as 宋体), color=000000, sz=20, no explicit alignment

What I tried

query --compact located the image paragraph quickly, and get showed the reference tables. For the build I ended up editing word/document.xml directly (clone a neighbor tblPr, rebuild 21 rows), because doing it purely through the CLI felt like 40+ incremental calls for one table.

What works well today

To be fair, most pieces already exist:

  • add /body --type table --prop rows/cols/data/colWidths/width/style/tblLook/borders
  • add /body --from /body/tbl[N] table clone, plus column --from clone
  • set .../tc[C] --prop text/font/size/bold/color/align/width/fill

So this is a feature request, not a "nothing works" bug. My earlier assumption that "OfficeCLI can't replicate tblPr/tcW/rPr" was wrong — it can, just step by step.

Gaps I hit

  1. No one-shot "clone this table's look, but with different shape/data". I wanted something like: copy tbl[12]'s style grid, then supply 21x2 data. --from clones size too, so I still had to reshape row by row.
  2. CJK fidelity: cell font= seems ASCII-only (readback says RunFonts.Ascii). I could not set eastAsia="黑体" separately from ascii/cs, which matters for Chinese headers.
  3. Asymmetric sz/szCs: header needed sz=21 + szCs=24. Cell size=10.5pt presumably sets both to the same value, with no sizeCs-style knob.
  4. Positional replace: add table appends at the end. Replacing an image paragraph in the middle meant add + move --index + remove of the image para across several calls, each shifting indices.

Rough guesses (not prescriptions)

  • Perhaps allow add --from <table> --prop data=... --prop rows/cols=... to keep style/grid look while reseeding shape and text.
  • Perhaps expose fontEastAsia / fontCs and sizeCs alongside the existing font/size, so CJK + Latin can diverge the way Word stores them.
  • Perhaps document a short "replace image-para with styled table" recipe, since screenshot-tables are a common cleanup task.

Happy to provide a minimal repro doc if it helps. Thanks for the great help system — it made the gap easy to verify before filing.


Env: officecli 1.0.149, Windows + pwsh. Wiki pages checked: word-table, word-table-add/get/set, word-reference (--from copy).