lmoffice authoring skill

lmoffice is a self-contained .NET 8 NativeAOT lmcode host for LMScript that creates, validates, and extracts Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) Open XML documents without requiring Microsoft Office or network access.

Purpose

Use lmoffice to author typed Word documents, multi-sheet Excel workbooks with formulas and native charts, and 16:9 PowerPoint slide decks from LMScript _lmcode_ blocks, or to inspect and convert existing Open XML packages to JSON summaries and canonical Markdown.

When to use it

Choose lmoffice when a workflow needs editable Office Open XML deliverables (.docx, .xlsx, .pptx) or structured inspection of existing Office packages. Use lmpdf instead when the final output must be an archival PDF/A-2b and PDF/UA-1 document or slide deck from the same docx or pptx calls.

Install

Install the lmctl CLI globally with npm, or let LMScript resolve the pinned GitHub release binary automatically via install="github:lmctl-ai/lmoffice@v0.1.33" on first execution.

npm install -g @lmctl-ai/lmctl
lmoffice --version
lmoffice docx --help
lmoffice inspect report.docx

Commands

Each document format has its own subcommand and embedded schema (lmoffice docx, lmoffice xlsx, lmoffice pptx), while inspect is a shared top-level command that validates any .docx, .xlsx, or .pptx package with OpenXmlValidator and prints a JSON summary.

lmoffice --version
lmoffice docx --lmcode-schema --json
lmoffice docx --lmcode-signatures
lmoffice docx --lmcode invocation.json
lmoffice xlsx --lmcode-schema --json
lmoffice xlsx --lmcode-signatures
lmoffice xlsx --lmcode invocation.json
lmoffice pptx --lmcode-schema --json
lmoffice pptx --lmcode-signatures
lmoffice pptx --lmcode invocation.json
lmoffice inspect report.docx
lmoffice inspect report.docx --markdown

Inputs and outputs

Each format subcommand exposes a single root context variable (docx: DocxHost, xlsx: XlsxHost, or pptx: PptxHost) alongside the standard lmcode_std_v3 catalog. Context factories create(path) return format handles (Docx, Xlsx, Pptx) whose save() method writes the package; the host then writes a terminal LMCODE_RETURN result frame.

Safety rules

Worked examples

Create a Word weekly brief from an inline Markdown string and verify the execution envelope:

body = """# Weekly brief

- **Shipped:** the pilot workflow
- **Next:** customer feedback

{{sign: Avery Chen}}
""";
p = _lmcode_ cli="lmoffice docx" install="github:lmctl-ai/lmoffice@v0.1.33";
docx.create("brief.docx").markdown(${body}).save();
end _lmcode_
r = run_lmcode(p);
assert(r.ok, json_stringify(r));

Create an Excel departmental budget with formulas, formatting, and a frozen header row:

p = _lmcode_ cli="lmoffice xlsx" install="github:lmctl-ai/lmoffice@v0.1.33";
let wb = xlsx.create("budget.xlsx");
let s = wb.sheet("Q1");
s.set(1, 1, "Category").set(1, 2, "Planned").set(1, 3, "Actual").set(1, 4, "Variance");
s.bold(1, 1).bold(1, 2).bold(1, 3).bold(1, 4).freeze(1, 0);
s.set(2, 1, "Compute").set(2, 2, 12000.0).set(2, 3, 11450.0).formula(2, 4, "C2-B2");
s.set(3, 1, "Storage").set(3, 2, 4500.0).set(3, 3, 4620.0).formula(3, 4, "C3-B3");
s.number_format(2, 2, "$#,##0.00").number_format(2, 3, "$#,##0.00").number_format(2, 4, "$#,##0.00");
wb.save();
end _lmcode_
r = run_lmcode(p);
assert(r.ok, json_stringify(r));

Errors and exit codes

Exit code 0 indicates success and emits a terminal LMCODE_RETURN frame with ok set to true. Exit code 2 indicates an invalid command or manifest. Exit code 3 indicates an lmcode or VM run failure. Exit code 4 indicates an application or document failure.

How to verify

Verify schema parity and validate every generated .docx, .xlsx, or .pptx package with lmoffice inspect, which runs OpenXmlValidator before returning format counts and extracted text:

lmoffice docx --lmcode-schema --json > /tmp/docx.schema.json
lmoffice docx --lmcode-signatures > /tmp/docx.sigs.txt
lmscript --lmcode-signatures /tmp/docx.schema.json > /tmp/docx.compiler.txt
diff -u /tmp/docx.compiler.txt /tmp/docx.sigs.txt
lmoffice inspect brief.docx
lmoffice inspect brief.docx --markdown