LibreOffice 实战教程
📄 LibreOffice CLI 实战教程
Section titled “📄 LibreOffice CLI 实战教程”LibreOffice 是最完整的开源办公套件。通过 CLI-Anything,AI Agent 可以自动处理 Writer(文档)、Calc(表格)、Impress(演示)三大组件。
📦 安装 LibreOffice CLI
Section titled “📦 安装 LibreOffice CLI”pip install cli-anything-hubcli-hub install libreoffice🎯 实战 1:文档批量转 PDF
Section titled “🎯 实战 1:文档批量转 PDF”场景:将项目文档目录下所有 .docx 转为 PDF。
# 单文件转换cli-anything-libreoffice writer convert --input ./report.docx --format pdf --output ./report.pdf
# 批量转换for f in ./docs/*.docx; do cli-anything-libreoffice writer convert --input "$f" --format pdfdoneAI Agent 版本
Section titled “AI Agent 版本”把 ./docs/ 下所有 Word 文档转为 PDF,保存到 ./pdfs/ 目录🎯 实战 2:Excel 数据读取与图表生成
Section titled “🎯 实战 2:Excel 数据读取与图表生成”场景:从 Excel 读取销售数据,生成图表插入文档。
# 读取数据cli-anything-libreoffice calc read --file ./sales.xlsx --sheet "Q1" --range A1:D20 --format json
# 生成图表cli-anything-libreoffice calc chart --file ./sales.xlsx --type bar --data-range "A1:D20" --title "Q1 销售数据" --output ./chart.pngAI Agent 版本
Section titled “AI Agent 版本”读取 ./sales.xlsx 的 Q1 工作表 A1:D20 数据,生成柱状图,然后创建一个 Word 文档,插入数据和图表Agent 会自动组合 Writer + Calc CLI 调用完成。
🎯 实战 3:批量生成报告
Section titled “🎯 实战 3:批量生成报告”场景:从模板批量生成个性化报告。
cli-anything-libreoffice writer fill-template --template ./template.docx --data ./data.json --output ./reports/data.json 示例:
[ {"name": "张三", "score": 92, "rank": 1}, {"name": "李四", "score": 85, "rank": 2}, {"name": "王五", "score": 78, "rank": 3}]🎯 实战 4:PPT 自动生成
Section titled “🎯 实战 4:PPT 自动生成”场景:从数据自动创建演示文稿。
cli-anything-libreoffice impress create --template ./pitch.potx --data ./slides.json --output ./presentation.pptx📊 性能对比
Section titled “📊 性能对比”| 操作 | 手动操作 | CLI + AI(自动) |
|---|---|---|
| 50 个文档转 PDF | ~30 分钟 | ~3 分钟 |
| 生成 100 份报告 | ~200 分钟 | ~10 分钟 |
| Excel 图表 + 文档组合 | ~15 分钟 | ~1 分钟 |
🐛 常见问题
Section titled “🐛 常见问题”Q: 中文乱码
Section titled “Q: 中文乱码”确保系统安装了中文字体:
# Ubuntusudo apt install fonts-noto-cjk
# macOS# 系统自带中文字体,无需额外安装Q: LibreOffice 未安装
Section titled “Q: LibreOffice 未安装”- Windows:下载安装包
- macOS:
brew install --cask libreoffice - Linux:
sudo apt install libreoffice