← 返回
内容创作 中文

ODT File Manager & Editor

Create, parse, and edit ODT (OpenDocument Text) files locally using Python and odfdo. Use when the user asks to create, edit, read, update, append to, inspec...
使用 Python 和 odfdo 库在本地创建、解析和编辑 ODT(OpenDocument Text)文件,适用于用户要求创建、编辑、读取、更新、追加、检查...
juicyroots
内容创作 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 507
下载
💾 6
安装
1
版本
#latest

概述

ODT File Manager

Local ODT document creation and editing powered by odfdo.

Library: odfdo v3.20+ — actively maintained, single dep (lxml), full ODF support.

Required Setup

pip install odfdo

Skill Boundaries

This skill is purely local — it has no network access and knows nothing about NextCloud.

For NextCloud workflows, pair with nextcloud-aio-oc:

StepSkill
-------------
Find file on NextCloudnextcloud-aio-ocnode scripts/nextcloud.js files search
Download binary ODTnextcloud-aio-ocpython3 scripts/files_binary.py download
Edit / create ODTodt-filemgr-ocpython3 scripts/odt_tool.py ...
Upload binary ODTnextcloud-aio-ocpython3 scripts/files_binary.py upload

Scripts live at: ~/.openclaw/skills/odt-filemgr-oc/scripts/


Workflows

Edit an existing ODT (NextCloud)

NC=~/.openclaw/skills/nextcloud-aio-oc/scripts
ODT=~/.openclaw/skills/odt-filemgr-oc/scripts

# 1. Download
python3 $NC/files_binary.py download "/Documents/MyDoc.odt" /tmp/MyDoc.odt

# 2. Inspect
python3 $ODT/odt_tool.py inspect /tmp/MyDoc.odt

# 3. Edit
python3 $ODT/odt_tool.py append /tmp/MyDoc.odt --text "New Section" --heading 2
python3 $ODT/odt_tool.py append /tmp/MyDoc.odt --text "Section content here."

# 4. Upload back
python3 $NC/files_binary.py upload /tmp/MyDoc.odt "/Documents/MyDoc.odt"

Create a new ODT and push to NextCloud

# 1. Create locally
python3 $ODT/odt_tool.py create /tmp/NewDoc.odt --title "Q1 Report"

# 2. Add content
python3 $ODT/odt_tool.py append /tmp/NewDoc.odt --text "Summary" --heading 2
python3 $ODT/odt_tool.py append /tmp/NewDoc.odt --text "Results were positive across all metrics."

# 3. Push to NextCloud
python3 $NC/files_binary.py upload /tmp/NewDoc.odt "/Documents/Q1 Report.odt"

Edit a local ODT (no NextCloud)

python3 $ODT/odt_tool.py inspect   myfile.odt
python3 $ODT/odt_tool.py to-text   myfile.odt
python3 $ODT/odt_tool.py append    myfile.odt --text "Added paragraph."
python3 $ODT/odt_tool.py replace   myfile.odt --find "draft" --sub "final"
python3 $ODT/odt_tool.py set-meta  myfile.odt --title "Final Report"

odt_tool.py Commands

CommandDescription
----------------------
inspect Show metadata + paragraph/heading/table structure
to-text Extract all text content in document order
create [--title T]Create blank ODT (optional H1 title)
append --text T [--heading N] [--style S]Append heading (N=1–6) or paragraph
replace --find F --sub S [--regex]Find and replace text
set-meta [--title T] [--subject S] [--description D]Update metadata
set-font --font F [--size N] [--no-preserve-mono]Set font across all style layers (default + all named/inline overrides)
`set-outline --numbered \--plain`Toggle heading numbering (1.1.1 or none)
merge-styles --template TApply all styles from a template ODT

Custom Python Edits

For table edits, style changes, or multi-step operations, write inline Python:

from odfdo import Document, Header, Paragraph

doc = Document("/tmp/file.odt")
body = doc.body

# Read all content in order
for child in body.children:
    if isinstance(child, Header):
        print(f"H{child.level}: {child.inner_text}")
    elif isinstance(child, Paragraph) and child.inner_text.strip():
        print(f"[{child.style}]: {child.inner_text}")

# Add content
body.append(Header(2, "New Section"))
body.append(Paragraph("Content here."))

# Table edit
table = body.get_table_by_name("MyTable")
table.set_value(0, 0, "Updated cell")

doc.save("/tmp/file.odt", pretty=True)

For the full odfdo API (tables, lists, spans, styles, metadata), see REFERENCE.md.


Key Rules

  1. Always inspect before editing a file you haven't seen.
  2. Temp files: use /tmp/ for working files; clean up after upload.
  3. Styles: for complex style systems (colors, spacing, borders), use merge-styles with a template rather than generating styles from scratch. set-font and set-outline work safely on any document without a template.

Troubleshooting

ErrorFix
------------
ModuleNotFoundError: odfdopip install odfdo
zipfile.BadZipFileFile corrupted or not a real ODT — re-download
Heading doesn't appear as H1Use Header(1, "text"), not Paragraph("text", style="Heading 1")
Font still shows as Liberation in CollaboraODT has 6 font attributes per style rule. Old approach only set 3 (style:font-name-*). Collabora renders from fo:font-family — now all 6 are set. Re-run set-font.
Font name must match exactlyLibreOffice/Collabora font names are case-sensitive: "Noto Sans" not "noto sans"
set-outline changes not visibleSome documents override numbering via paragraph styles — use merge-styles with a clean template instead

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 00:05 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

content-creation

AdMapix

fly0pants
广告情报与应用数据分析助手,支持搜索广告素材、分析应用排名、下载量、收入及市场洞察,用于广告素材和竞品分析。
★ 295 📥 136,405
content-creation

Baidu Wenku AIPPT

ide-rea
使用百度文库 AI 智能生成 PPT,自动根据内容选择模板。
★ 66 📥 46,131
content-creation

Humanizer

biostartechnology
消除AI写作痕迹,使文本更自然真实。基于维基百科"AI写作特征"指南,识别并修正夸张象征、宣传用语、肤浅-ing分析、模糊归因、破折号滥用、三项排比、AI词汇、负面平行结构及冗长连接词等模式。
★ 857 📥 199,269