edit 编辑

已有 Office 文件做结构化修改;也可 validate / view / 读辅助 op。

基本用法

zagens-office edit --path file.pptx --op validate --input '{}'
zagens-office edit --path file.pptx --op set_text --input-file op.json

schema edit 列出全部 op(约 95 个),跨 pptx/docx/xlsx 等统一命名。

常用能力(摘要)

能力 说明
upsert_slide write pptx 同构的整页替换/追加(长 deck:骨架 write → 逐页 upsert)
preflight / auto_fix 跨格式预检;auto_fix 可返回可重放 plan
fit_text / avoid_overlap PPTX 文本适配与消重叠
align / distribute / snap_to_grid PPTX 对齐、分布、网格吸附
XLSX 深度编辑 批注、命名区域、插删行列表格/批注 remap

完整清单以 schema edit 为准。

原子批量

多步修改用一次 batch,失败可整体回滚:

{
  "ops": [
    { "op": "set_text", "...": "..." },
    { "op": "upsert_slide", "...": "..." }
  ],
  "atomic": true
}
zagens-office edit --path file.pptx --op batch --input-file batch.json

注意:失败时外层信封可能仍是 ok:true,以 result.rolled_back:true 为准。

常用只读 / 检查

目的 做法
交付自检 edit --op validate
结构预览 edit --op view --input '{"mode":"svg"}'
读大纲 / 正文 read pptx|docx --mode outline|text|stats
读表 read xlsx --mode table(扫结构)或 grid(填坐标)

read / schema 不需要授权。改前建议先 read,再 batch 自愈。

相关