officecli-office-automation
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOfficeCLI Office Automation Skill
OfficeCLI 办公自动化技能
Skill by ara.so — Devtools Skills collection.
OfficeCLI is an Office suite purpose-built for AI agents to create, read, and edit Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) files. It's a single binary with no Office installation required, featuring a unified CLI interface and built-in rendering to HTML/PNG.
由ara.so提供的技能——开发工具技能合集。
OfficeCLI是一款专为AI Agent打造的办公套件,用于创建、读取和编辑Word(.docx)、Excel(.xlsx)和PowerPoint(.pptx)文件。它是一个独立二进制文件,无需安装Office,具备统一的CLI界面和内置的HTML/PNG渲染功能。
Installation
安装
macOS / Linux:
bash
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bashWindows (PowerShell):
powershell
irm https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.ps1 | iexManual installation:
- Download the binary for your platform from GitHub Releases
- Run to add to PATH
officecli install
Verify installation:
bash
officecli --versionmacOS / Linux:
bash
curl -fsSL https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.sh | bashWindows (PowerShell):
powershell
irm https://raw.githubusercontent.com/iOfficeAI/OfficeCLI/main/install.ps1 | iex手动安装:
- 从GitHub Releases下载对应平台的二进制文件
- 运行添加到PATH
officecli install
验证安装:
bash
officecli --versionCore Commands
核心命令
File Operations
文件操作
Create a new document:
bash
undefined创建新文档:
bash
undefinedBlank files
空白文件
officecli create document.docx
officecli create spreadsheet.xlsx
officecli create presentation.pptx
officecli create document.docx
officecli create spreadsheet.xlsx
officecli create presentation.pptx
With initial content
带初始内容
officecli create report.docx --prop title="Q4 Report"
**View document content:**
```bashofficecli create report.docx --prop title="Q4 Report"
**查看文档内容:**
```bashView as outline (tree structure)
以大纲(树形结构)查看
officecli view document.docx outline
officecli view document.docx outline
View as plain text
以纯文本查看
officecli view document.docx text
officecli view document.docx text
View as HTML (opens in browser)
以HTML查看(在浏览器中打开)
officecli view document.docx html
officecli view document.docx html
View as JSON structure
以JSON结构查看
officecli view document.docx json
**Get specific elements:**
```bashofficecli view document.docx json
**获取特定元素:**
```bashGet element details as JSON
以JSON格式获取元素详情
officecli get document.docx '/paragraph[1]' --json
officecli get spreadsheet.xlsx '$Sheet1:A1' --json
officecli get presentation.pptx '/slide[1]/shape[2]' --json
undefinedofficecli get document.docx '/paragraph[1]' --json
officecli get spreadsheet.xlsx '$Sheet1:A1' --json
officecli get presentation.pptx '/slide[1]/shape[2]' --json
undefinedLive Preview
实时预览
Watch mode (auto-refresh in browser):
bash
undefined监听模式(浏览器自动刷新):
bash
undefinedStart live preview server on http://localhost:26315
officecli watch presentation.pptx
officecli watch presentation.pptx
Custom port
自定义端口
officecli watch presentation.pptx --port 8080
officecli watch presentation.pptx --port 8080
Every edit you make will auto-refresh the browser
你进行的每一次编辑都会自动刷新浏览器
undefinedundefinedWord Documents (.docx)
Word文档 (.docx)
Path Syntax
路径语法
- - Nth paragraph (1-indexed)
/paragraph[N] - - Mth run in Nth paragraph
/paragraph[N]/run[M] - - Nth table
/table[N] - - Cell in table
/table[N]/row[R]/cell[C]
- - 第N个段落(从1开始计数)
/paragraph[N] - - 第N个段落中的第M个文本段
/paragraph[N]/run[M] - - 第N个表格
/table[N] - - 表格中的单元格
/table[N]/row[R]/cell[C]
Add Content
添加内容
Add paragraphs:
bash
undefined添加段落:
bash
undefinedSimple paragraph
简单段落
officecli add report.docx / --type paragraph --prop text="Executive Summary"
officecli add report.docx / --type paragraph --prop text="Executive Summary"
Styled paragraph
带样式的段落
officecli add report.docx / --type paragraph
--prop text="Quarterly Revenue Analysis"
--prop style=Heading1
--prop align=center
--prop text="Quarterly Revenue Analysis"
--prop style=Heading1
--prop align=center
officecli add report.docx / --type paragraph
--prop text="Quarterly Revenue Analysis"
--prop style=Heading1
--prop align=center
--prop text="Quarterly Revenue Analysis"
--prop style=Heading1
--prop align=center
With formatting
带格式的段落
officecli add report.docx / --type paragraph
--prop text="Important notice"
--prop bold=true
--prop color=FF0000
--prop size=14
--prop text="Important notice"
--prop bold=true
--prop color=FF0000
--prop size=14
**Add runs (inline formatting):**
```bash
officecli add report.docx '/paragraph[1]' --type run \
--prop text="bold text" \
--prop bold=trueAdd tables:
bash
undefinedofficecli add report.docx / --type paragraph
--prop text="Important notice"
--prop bold=true
--prop color=FF0000
--prop size=14
--prop text="Important notice"
--prop bold=true
--prop color=FF0000
--prop size=14
**添加文本段(内联格式):**
```bash
officecli add report.docx '/paragraph[1]' --type run \
--prop text="bold text" \
--prop bold=true添加表格:
bash
undefined3x3 table
3x3表格
officecli add report.docx / --type table
--prop rows=3
--prop cols=3
--prop rows=3
--prop cols=3
officecli add report.docx / --type table
--prop rows=3
--prop cols=3
--prop rows=3
--prop cols=3
Set cell content
设置单元格内容
officecli set report.docx '/table[1]/row[1]/cell[1]'
--prop text="Header 1"
--prop text="Header 1"
**Add images:**
```bash
officecli add report.docx / --type picture \
--prop src=chart.png \
--prop width=15cm \
--prop height=10cmAdd headers/footers:
bash
undefinedofficecli set report.docx '/table[1]/row[1]/cell[1]'
--prop text="Header 1"
--prop text="Header 1"
**添加图片:**
```bash
officecli add report.docx / --type picture \
--prop src=chart.png \
--prop width=15cm \
--prop height=10cm添加页眉/页脚:
bash
undefinedAdd header to first section
为第一节添加页眉
officecli add report.docx '/section[1]' --type header
--prop type=default
--prop type=default
officecli add report.docx '/section[1]' --type header
--prop type=default
--prop type=default
Add content to header
为页眉添加内容
officecli add report.docx '/section[1]/header[1]' --type paragraph
--prop text="Confidential Report"
--prop align=right
--prop text="Confidential Report"
--prop align=right
undefinedofficecli add report.docx '/section[1]/header[1]' --type paragraph
--prop text="Confidential Report"
--prop align=right
--prop text="Confidential Report"
--prop align=right
undefinedModify Content
修改内容
Set paragraph properties:
bash
officecli set report.docx '/paragraph[1]' \
--prop text="Updated title" \
--prop style=Heading1 \
--prop align=center \
--prop spaceBefore=240 \
--prop spaceAfter=120Set run properties:
bash
officecli set report.docx '/paragraph[2]/run[1]' \
--prop bold=true \
--prop italic=true \
--prop font=Arial \
--prop size=12 \
--prop color=0000FF设置段落属性:
bash
officecli set report.docx '/paragraph[1]' \
--prop text="Updated title" \
--prop style=Heading1 \
--prop align=center \
--prop spaceBefore=240 \
--prop spaceAfter=120设置文本段属性:
bash
officecli set report.docx '/paragraph[2]/run[1]' \
--prop bold=true \
--prop italic=true \
--prop font=Arial \
--prop size=12 \
--prop color=0000FFRemove Content
删除内容
bash
undefinedbash
undefinedRemove paragraph
删除段落
officecli remove report.docx '/paragraph[3]'
officecli remove report.docx '/paragraph[3]'
Remove table
删除表格
officecli remove report.docx '/table[1]'
undefinedofficecli remove report.docx '/table[1]'
undefinedRTL and i18n Support
RTL与国际化支持
bash
undefinedbash
undefinedRTL paragraph (Arabic, Hebrew)
RTL段落(阿拉伯语、希伯来语)
officecli add report.docx / --type paragraph
--prop text="مرحبا بك"
--prop direction=rtl
--prop lang.cs=ar-SA
--prop text="مرحبا بك"
--prop direction=rtl
--prop lang.cs=ar-SA
officecli add report.docx / --type paragraph
--prop text="مرحبا بك"
--prop direction=rtl
--prop lang.cs=ar-SA
--prop text="مرحبا بك"
--prop direction=rtl
--prop lang.cs=ar-SA
Per-script fonts
按脚本设置字体
officecli add report.docx / --type paragraph
--prop text="Hello 世界 مرحبا"
--prop font.latin=Arial
--prop font.ea="MS Gothic"
--prop font.cs="Arial Unicode MS"
--prop text="Hello 世界 مرحبا"
--prop font.latin=Arial
--prop font.ea="MS Gothic"
--prop font.cs="Arial Unicode MS"
undefinedofficecli add report.docx / --type paragraph
--prop text="Hello 世界 مرحبا"
--prop font.latin=Arial
--prop font.ea="MS Gothic"
--prop font.cs="Arial Unicode MS"
--prop text="Hello 世界 مرحبا"
--prop font.latin=Arial
--prop font.ea="MS Gothic"
--prop font.cs="Arial Unicode MS"
undefinedExcel Spreadsheets (.xlsx)
Excel电子表格 (.xlsx)
Cell Addressing
单元格寻址
- - Cell A1 in named sheet
$SheetName:A1 - - Range B2:D4
$Sheet1:B2:D4 - - Path-based addressing
/sheet[1]/cell[A1]
- - 指定工作表中的A1单元格
$SheetName:A1 - - B2到D4的单元格区域
$Sheet1:B2:D4 - - 基于路径的寻址方式
/sheet[1]/cell[A1]
Add Content
添加内容
Add sheets:
bash
undefined添加工作表:
bash
undefinedAdd new sheet
添加新工作表
officecli add budget.xlsx / --type sheet --prop name="Q1 Budget"
officecli add budget.xlsx / --type sheet --prop name="Q1 Budget"
Add with properties
添加带属性的工作表
officecli add budget.xlsx / --type sheet
--prop name="Summary"
--prop tabColor=FF0000
--prop state=visible
--prop name="Summary"
--prop tabColor=FF0000
--prop state=visible
**Add cells:**
```bashofficecli add budget.xlsx / --type sheet
--prop name="Summary"
--prop tabColor=FF0000
--prop state=visible
--prop name="Summary"
--prop tabColor=FF0000
--prop state=visible
**添加单元格:**
```bashSimple value
简单值
officecli add budget.xlsx '$Sheet1:A1' --type cell
--prop value="Revenue"
--prop value="Revenue"
officecli add budget.xlsx '$Sheet1:A1' --type cell
--prop value="Revenue"
--prop value="Revenue"
Number with formatting
带格式的数字
officecli add budget.xlsx '$Sheet1:B1' --type cell
--prop value=125000
--prop format='$#,##0.00'
--prop value=125000
--prop format='$#,##0.00'
officecli add budget.xlsx '$Sheet1:B1' --type cell
--prop value=125000
--prop format='$#,##0.00'
--prop value=125000
--prop format='$#,##0.00'
Formula
公式
officecli add budget.xlsx '$Sheet1:C1' --type cell
--prop formula='=SUM(B1:B10)'
--prop formula='=SUM(B1:B10)'
officecli add budget.xlsx '$Sheet1:C1' --type cell
--prop formula='=SUM(B1:B10)'
--prop formula='=SUM(B1:B10)'
Date
日期
officecli add budget.xlsx '$Sheet1:D1' --type cell
--prop value=2024-01-15
--prop format='yyyy-mm-dd'
--prop value=2024-01-15
--prop format='yyyy-mm-dd'
**Batch add cells:**
```bashofficecli add budget.xlsx '$Sheet1:D1' --type cell
--prop value=2024-01-15
--prop format='yyyy-mm-dd'
--prop value=2024-01-15
--prop format='yyyy-mm-dd'
**批量添加单元格:**
```bashMultiple cells
多个单元格
officecli add budget.xlsx '$Sheet1:A1' --type cell --prop value="Name"
officecli add budget.xlsx '$Sheet1:B1' --type cell --prop value="Amount"
officecli add budget.xlsx '$Sheet1:A2' --type cell --prop value="Sales"
officecli add budget.xlsx '$Sheet1:B2' --type cell --prop value=50000
**Add tables:**
```bashofficecli add budget.xlsx '$Sheet1:A1' --type cell --prop value="Name"
officecli add budget.xlsx '$Sheet1:B1' --type cell --prop value="Amount"
officecli add budget.xlsx '$Sheet1:A2' --type cell --prop value="Sales"
officecli add budget.xlsx '$Sheet1:B2' --type cell --prop value=50000
**添加表格:**
```bashCreate table from range
从单元格区域创建表格
officecli add budget.xlsx '$Sheet1:A1:C10' --type table
--prop name="SalesData"
--prop style=TableStyleMedium2
--prop showHeader=true
--prop name="SalesData"
--prop style=TableStyleMedium2
--prop showHeader=true
**Add charts:**
```bashofficecli add budget.xlsx '$Sheet1:A1:C10' --type table
--prop name="SalesData"
--prop style=TableStyleMedium2
--prop showHeader=true
--prop name="SalesData"
--prop style=TableStyleMedium2
--prop showHeader=true
**添加图表:**
```bashColumn chart
柱状图
officecli add budget.xlsx '$Sheet1' --type chart
--prop chartType=column
--prop dataRange='$Sheet1:A1:B10'
--prop title="Sales by Region"
--prop x=5cm
--prop y=2cm
--prop chartType=column
--prop dataRange='$Sheet1:A1:B10'
--prop title="Sales by Region"
--prop x=5cm
--prop y=2cm
officecli add budget.xlsx '$Sheet1' --type chart
--prop chartType=column
--prop dataRange='$Sheet1:A1:B10'
--prop title="Sales by Region"
--prop x=5cm
--prop y=2cm
--prop chartType=column
--prop dataRange='$Sheet1:A1:B10'
--prop title="Sales by Region"
--prop x=5cm
--prop y=2cm
Pie chart
饼图
officecli add budget.xlsx '$Sheet1' --type chart
--prop chartType=pie
--prop dataRange='$Sheet1:A1:B5'
--prop title="Market Share"
--prop chartType=pie
--prop dataRange='$Sheet1:A1:B5'
--prop title="Market Share"
**Add pivot tables:**
```bash
officecli add budget.xlsx '$Sheet2:A1' --type pivottable \
--prop sourceRange='$Sheet1:A1:D100' \
--prop rowFields=Region \
--prop dataFields=Sales \
--prop name="SalesByRegion"officecli add budget.xlsx '$Sheet1' --type chart
--prop chartType=pie
--prop dataRange='$Sheet1:A1:B5'
--prop title="Market Share"
--prop chartType=pie
--prop dataRange='$Sheet1:A1:B5'
--prop title="Market Share"
**添加数据透视表:**
```bash
officecli add budget.xlsx '$Sheet2:A1' --type pivottable \
--prop sourceRange='$Sheet1:A1:D100' \
--prop rowFields=Region \
--prop dataFields=Sales \
--prop name="SalesByRegion"Modify Content
修改内容
Set cell values:
bash
officecli set budget.xlsx '$Sheet1:A1' --prop value="Updated"设置单元格值:
bash
officecli set budget.xlsx '$Sheet1:A1' --prop value="Updated"With formatting
带格式设置
officecli set budget.xlsx '$Sheet1:B2'
--prop value=75000
--prop format='$#,##0.00'
--prop bold=true
--prop color=FF0000
--prop value=75000
--prop format='$#,##0.00'
--prop bold=true
--prop color=FF0000
**Set sheet properties:**
```bash
officecli set budget.xlsx '/sheet[1]' \
--prop name="Renamed Sheet" \
--prop tabColor=00FF00 \
--prop direction=rtlofficecli set budget.xlsx '$Sheet1:B2'
--prop value=75000
--prop format='$#,##0.00'
--prop bold=true
--prop color=FF0000
--prop value=75000
--prop format='$#,##0.00'
--prop bold=true
--prop color=FF0000
**设置工作表属性:**
```bash
officecli set budget.xlsx '/sheet[1]' \
--prop name="Renamed Sheet" \
--prop tabColor=00FF00 \
--prop direction=rtlFormulas
公式
150+ built-in functions with auto-evaluation:
bash
undefined150+内置函数,支持自动计算:
bash
undefinedMath
数学函数
officecli add budget.xlsx '$Sheet1:C1' --type cell
--prop formula='=SUM(A1:A10)'
--prop formula='=SUM(A1:A10)'
officecli add budget.xlsx '$Sheet1:C1' --type cell
--prop formula='=SUM(A1:A10)'
--prop formula='=SUM(A1:A10)'
Conditional
条件函数
officecli add budget.xlsx '$Sheet1:D1' --type cell
--prop formula='=IF(B1>1000,"High","Low")'
--prop formula='=IF(B1>1000,"High","Low")'
officecli add budget.xlsx '$Sheet1:D1' --type cell
--prop formula='=IF(B1>1000,"High","Low")'
--prop formula='=IF(B1>1000,"High","Low")'
Lookup
查找函数
officecli add budget.xlsx '$Sheet1:E1' --type cell
--prop formula='=VLOOKUP(A1,$Sheet2:A:B,2,FALSE)'
--prop formula='=VLOOKUP(A1,$Sheet2:A:B,2,FALSE)'
officecli add budget.xlsx '$Sheet1:E1' --type cell
--prop formula='=VLOOKUP(A1,$Sheet2:A:B,2,FALSE)'
--prop formula='=VLOOKUP(A1,$Sheet2:A:B,2,FALSE)'
Date functions
日期函数
officecli add budget.xlsx '$Sheet1:F1' --type cell
--prop formula='=TODAY()'
--prop formula='=TODAY()'
undefinedofficecli add budget.xlsx '$Sheet1:F1' --type cell
--prop formula='=TODAY()'
--prop formula='=TODAY()'
undefinedSort Data
数据排序
bash
undefinedbash
undefinedSort range by column
按列对区域排序
officecli add budget.xlsx '$Sheet1:A1:C10' --type sort
--prop key1=B
--prop order1=desc
--prop key1=B
--prop order1=desc
officecli add budget.xlsx '$Sheet1:A1:C10' --type sort
--prop key1=B
--prop order1=desc
--prop key1=B
--prop order1=desc
Multi-key sort
多关键字排序
officecli add budget.xlsx '$Sheet1:A1:D20' --type sort
--prop key1=A
--prop order1=asc
--prop key2=B
--prop order2=desc
--prop key1=A
--prop order1=asc
--prop key2=B
--prop order2=desc
undefinedofficecli add budget.xlsx '$Sheet1:A1:D20' --type sort
--prop key1=A
--prop order1=asc
--prop key2=B
--prop order2=desc
--prop key1=A
--prop order1=asc
--prop key2=B
--prop order2=desc
undefinedConditional Formatting
条件格式
bash
officecli add budget.xlsx '$Sheet1:B2:B10' --type conditionalformatting \
--prop type=colorScale \
--prop minColor=FF0000 \
--prop maxColor=00FF00bash
officecli add budget.xlsx '$Sheet1:B2:B10' --type conditionalformatting \
--prop type=colorScale \
--prop minColor=FF0000 \
--prop maxColor=00FF00PowerPoint Presentations (.pptx)
PowerPoint演示文稿 (.pptx)
Path Syntax
路径语法
- - Nth slide
/slide[N] - - Mth shape on slide
/slide[N]/shape[M] - - Mth table on slide
/slide[N]/table[M]
- - 第N张幻灯片
/slide[N] - - 第N张幻灯片上的第M个形状
/slide[N]/shape[M] - - 第N张幻灯片上的第M个表格
/slide[N]/table[M]
Add Content
添加内容
Add slides:
bash
undefined添加幻灯片:
bash
undefinedBlank slide
空白幻灯片
officecli add deck.pptx / --type slide
officecli add deck.pptx / --type slide
With title
带标题的幻灯片
officecli add deck.pptx / --type slide
--prop title="Introduction"
--prop title="Introduction"
officecli add deck.pptx / --type slide
--prop title="Introduction"
--prop title="Introduction"
With background
带背景的幻灯片
officecli add deck.pptx / --type slide
--prop title="Dark Theme"
--prop background=1A1A2E
--prop title="Dark Theme"
--prop background=1A1A2E
**Add shapes (text boxes):**
```bashofficecli add deck.pptx / --type slide
--prop title="Dark Theme"
--prop background=1A1A2E
--prop title="Dark Theme"
--prop background=1A1A2E
**添加形状(文本框):**
```bashSimple text box
简单文本框
officecli add deck.pptx '/slide[1]' --type shape
--prop text="Hello World"
--prop x=2cm
--prop y=3cm
--prop width=10cm
--prop height=2cm
--prop text="Hello World"
--prop x=2cm
--prop y=3cm
--prop width=10cm
--prop height=2cm
officecli add deck.pptx '/slide[1]' --type shape
--prop text="Hello World"
--prop x=2cm
--prop y=3cm
--prop width=10cm
--prop height=2cm
--prop text="Hello World"
--prop x=2cm
--prop y=3cm
--prop width=10cm
--prop height=2cm
Styled text box
带样式的文本框
officecli add deck.pptx '/slide[1]' --type shape
--prop text="Key Findings"
--prop x=1cm
--prop y=2cm
--prop font=Arial
--prop size=32
--prop color=FFFFFF
--prop bold=true
--prop align=center
--prop text="Key Findings"
--prop x=1cm
--prop y=2cm
--prop font=Arial
--prop size=32
--prop color=FFFFFF
--prop bold=true
--prop align=center
**Add images:**
```bashofficecli add deck.pptx '/slide[1]' --type shape
--prop text="Key Findings"
--prop x=1cm
--prop y=2cm
--prop font=Arial
--prop size=32
--prop color=FFFFFF
--prop bold=true
--prop align=center
--prop text="Key Findings"
--prop x=1cm
--prop y=2cm
--prop font=Arial
--prop size=32
--prop color=FFFFFF
--prop bold=true
--prop align=center
**添加图片:**
```bashBasic image
基础图片
officecli add deck.pptx '/slide[1]' --type picture
--prop src=logo.png
--prop x=1cm
--prop y=1cm
--prop width=5cm
--prop height=3cm
--prop src=logo.png
--prop x=1cm
--prop y=1cm
--prop width=5cm
--prop height=3cm
officecli add deck.pptx '/slide[1]' --type picture
--prop src=logo.png
--prop x=1cm
--prop y=1cm
--prop width=5cm
--prop height=3cm
--prop src=logo.png
--prop x=1cm
--prop y=1cm
--prop width=5cm
--prop height=3cm
With effects
带效果的图片
officecli add deck.pptx '/slide[1]' --type picture
--prop src=photo.jpg
--prop x=5cm
--prop y=5cm
--prop brightness=20
--prop contrast=10
--prop shadow=true
--prop src=photo.jpg
--prop x=5cm
--prop y=5cm
--prop brightness=20
--prop contrast=10
--prop shadow=true
**Add tables:**
```bashofficecli add deck.pptx '/slide[1]' --type picture
--prop src=photo.jpg
--prop x=5cm
--prop y=5cm
--prop brightness=20
--prop contrast=10
--prop shadow=true
--prop src=photo.jpg
--prop x=5cm
--prop y=5cm
--prop brightness=20
--prop contrast=10
--prop shadow=true
**添加表格:**
```bashCreate table
创建表格
officecli add deck.pptx '/slide[1]' --type table
--prop rows=3
--prop cols=3
--prop x=2cm
--prop y=5cm
--prop rows=3
--prop cols=3
--prop x=2cm
--prop y=5cm
officecli add deck.pptx '/slide[1]' --type table
--prop rows=3
--prop cols=3
--prop x=2cm
--prop y=5cm
--prop rows=3
--prop cols=3
--prop x=2cm
--prop y=5cm
Set cell content
设置单元格内容
officecli set deck.pptx '/slide[1]/table[1]/row[1]/cell[1]'
--prop text="Header 1"
--prop bold=true
--prop text="Header 1"
--prop bold=true
**Add charts:**
```bash
officecli add deck.pptx '/slide[1]' --type chart \
--prop chartType=column \
--prop title="Sales Growth" \
--prop x=2cm \
--prop y=5cm \
--prop width=20cm \
--prop height=10cmAdd 3D models:
bash
officecli add deck.pptx '/slide[1]' --type 3dmodel \
--prop src=model.glb \
--prop x=5cm \
--prop y=5cm \
--prop width=10cm \
--prop height=10cmofficecli set deck.pptx '/slide[1]/table[1]/row[1]/cell[1]'
--prop text="Header 1"
--prop bold=true
--prop text="Header 1"
--prop bold=true
**添加图表:**
```bash
officecli add deck.pptx '/slide[1]' --type chart \
--prop chartType=column \
--prop title="Sales Growth" \
--prop x=2cm \
--prop y=5cm \
--prop width=20cm \
--prop height=10cm添加3D模型:
bash
officecli add deck.pptx '/slide[1]' --type 3dmodel \
--prop src=model.glb \
--prop x=5cm \
--prop y=5cm \
--prop width=10cm \
--prop height=10cmSlide Transitions and Animations
幻灯片切换与动画
Add transitions:
bash
officecli set deck.pptx '/slide[2]' \
--prop transition=morph \
--prop duration=1000Add animations:
bash
officecli add deck.pptx '/slide[1]/shape[1]' --type animation \
--prop effect=fadeIn \
--prop duration=500添加切换效果:
bash
officecli set deck.pptx '/slide[2]' \
--prop transition=morph \
--prop duration=1000添加动画:
bash
officecli add deck.pptx '/slide[1]/shape[1]' --type animation \
--prop effect=fadeIn \
--prop duration=500Modify Content
修改内容
Set shape properties:
bash
officecli set deck.pptx '/slide[1]/shape[1]' \
--prop text="Updated text" \
--prop font=Calibri \
--prop size=28 \
--prop color=333333 \
--prop fill=F0F0F0Set slide properties:
bash
officecli set deck.pptx '/slide[1]' \
--prop title="New Title" \
--prop background=FFFFFF \
--prop hidden=false设置形状属性:
bash
officecli set deck.pptx '/slide[1]/shape[1]' \
--prop text="Updated text" \
--prop font=Calibri \
--prop size=28 \
--prop color=333333 \
--prop fill=F0F0F0设置幻灯片属性:
bash
officecli set deck.pptx '/slide[1]' \
--prop title="New Title" \
--prop background=FFFFFF \
--prop hidden=falseSpeaker Notes
演讲者备注
bash
undefinedbash
undefinedAdd notes to slide
为幻灯片添加备注
officecli add deck.pptx '/slide[1]' --type notes
--prop text="Remember to mention the Q3 results"
--prop text="Remember to mention the Q3 results"
undefinedofficecli add deck.pptx '/slide[1]' --type notes
--prop text="Remember to mention the Q3 results"
--prop text="Remember to mention the Q3 results"
undefinedCommon Patterns
常见使用模式
Batch Document Generation
批量文档生成
bash
#!/bin/bashbash
#!/bin/bashGenerate monthly reports
生成月度报告
for month in Jan Feb Mar Apr; do
officecli create "report-${month}.docx"
officecli add "report-${month}.docx" / --type paragraph
--prop text="${month} Report"
--prop style=Heading1 officecli add "report-${month}.docx" / --type paragraph
--prop text="Generated on $(date)" done
--prop text="${month} Report"
--prop style=Heading1 officecli add "report-${month}.docx" / --type paragraph
--prop text="Generated on $(date)" done
undefinedfor month in Jan Feb Mar Apr; do
officecli create "report-${month}.docx"
officecli add "report-${month}.docx" / --type paragraph
--prop text="${month} Report"
--prop style=Heading1 officecli add "report-${month}.docx" / --type paragraph
--prop text="Generated on $(date)" done
--prop text="${month} Report"
--prop style=Heading1 officecli add "report-${month}.docx" / --type paragraph
--prop text="Generated on $(date)" done
undefinedCSV to Excel
CSV转Excel
bash
undefinedbash
undefinedImport CSV data
导入CSV数据
officecli create data.xlsx
officecli add data.xlsx '$Sheet1' --type import
--prop src=data.csv
--prop format=csv
--prop src=data.csv
--prop format=csv
undefinedofficecli create data.xlsx
officecli add data.xlsx '$Sheet1' --type import
--prop src=data.csv
--prop format=csv
--prop src=data.csv
--prop format=csv
undefinedMulti-slide Presentation from Template
基于模板的多幻灯片演示文稿
bash
#!/bin/bashbash
#!/bin/bashCreate presentation with consistent styling
创建样式统一的演示文稿
officecli create pitch.pptx
officecli create pitch.pptx
Title slide
标题幻灯片
officecli add pitch.pptx / --type slide
--prop title="Product Launch"
--prop background=1A1A2E
--prop title="Product Launch"
--prop background=1A1A2E
officecli add pitch.pptx / --type slide
--prop title="Product Launch"
--prop background=1A1A2E
--prop title="Product Launch"
--prop background=1A1A2E
Content slides
内容幻灯片
for topic in "Problem" "Solution" "Market" "Team"; do
officecli add pitch.pptx / --type slide
--prop title="$topic"
--prop background=1A1A2E
--prop title="$topic"
--prop background=1A1A2E
officecli add pitch.pptx '/slide[-1]' --type shape
--prop text="Content for $topic"
--prop x=2cm
--prop y=5cm
--prop color=FFFFFF done
--prop text="Content for $topic"
--prop x=2cm
--prop y=5cm
--prop color=FFFFFF done
undefinedfor topic in "Problem" "Solution" "Market" "Team"; do
officecli add pitch.pptx / --type slide
--prop title="$topic"
--prop background=1A1A2E
--prop title="$topic"
--prop background=1A1A2E
officecli add pitch.pptx '/slide[-1]' --type shape
--prop text="Content for $topic"
--prop x=2cm
--prop y=5cm
--prop color=FFFFFF done
--prop text="Content for $topic"
--prop x=2cm
--prop y=5cm
--prop color=FFFFFF done
undefinedAutomated Report with Charts
带图表的自动化报告
bash
#!/bin/bashbash
#!/bin/bashGenerate Excel report with chart
生成带图表的Excel报告
officecli create sales.xlsx
officecli create sales.xlsx
Add headers
添加表头
officecli add sales.xlsx '$Sheet1:A1' --type cell --prop value="Month"
officecli add sales.xlsx '$Sheet1:B1' --type cell --prop value="Revenue"
officecli add sales.xlsx '$Sheet1:A1' --type cell --prop value="Month"
officecli add sales.xlsx '$Sheet1:B1' --type cell --prop value="Revenue"
Add data
添加数据
officecli add sales.xlsx '$Sheet1:A2' --type cell --prop value="January"
officecli add sales.xlsx '$Sheet1:B2' --type cell --prop value=50000
officecli add sales.xlsx '$Sheet1:A3' --type cell --prop value="February"
officecli add sales.xlsx '$Sheet1:B3' --type cell --prop value=65000
officecli add sales.xlsx '$Sheet1:A4' --type cell --prop value="March"
officecli add sales.xlsx '$Sheet1:B4' --type cell --prop value=72000
officecli add sales.xlsx '$Sheet1:A2' --type cell --prop value="January"
officecli add sales.xlsx '$Sheet1:B2' --type cell --prop value=50000
officecli add sales.xlsx '$Sheet1:A3' --type cell --prop value="February"
officecli add sales.xlsx '$Sheet1:B3' --type cell --prop value=65000
officecli add sales.xlsx '$Sheet1:A4' --type cell --prop value="March"
officecli add sales.xlsx '$Sheet1:B4' --type cell --prop value=72000
Add chart
添加图表
officecli add sales.xlsx '$Sheet1' --type chart
--prop chartType=line
--prop dataRange='$Sheet1:A1:B4'
--prop title="Monthly Revenue"
--prop x=5cm
--prop y=2cm
--prop chartType=line
--prop dataRange='$Sheet1:A1:B4'
--prop title="Monthly Revenue"
--prop x=5cm
--prop y=2cm
undefinedofficecli add sales.xlsx '$Sheet1' --type chart
--prop chartType=line
--prop dataRange='$Sheet1:A1:B4'
--prop title="Monthly Revenue"
--prop x=5cm
--prop y=2cm
--prop chartType=line
--prop dataRange='$Sheet1:A1:B4'
--prop title="Monthly Revenue"
--prop x=5cm
--prop y=2cm
undefinedExtract and Transform
提取与转换
bash
#!/bin/bashbash
#!/bin/bashExtract text from Word doc, process, create new doc
从Word文档提取文本,处理后创建新文档
Extract text
提取文本
text=$(officecli view input.docx text)
text=$(officecli view input.docx text)
Process (example: convert to uppercase)
处理(示例:转换为大写)
processed=$(echo "$text" | tr '[:lower:]' '[:upper:]')
processed=$(echo "$text" | tr '[:lower:]' '[:upper:]')
Create new document
创建新文档
officecli create output.docx
officecli add output.docx / --type paragraph --prop text="$processed"
undefinedofficecli create output.docx
officecli add output.docx / --type paragraph --prop text="$processed"
undefinedIntegration with Scripts
与脚本集成
Python Integration
Python集成
python
import subprocess
import json
def create_report(title, content):
"""Create a Word document using OfficeCLI."""
filename = f"{title}.docx"
# Create document
subprocess.run(["officecli", "create", filename])
# Add title
subprocess.run([
"officecli", "add", filename, "/",
"--type", "paragraph",
"--prop", f"text={title}",
"--prop", "style=Heading1"
])
# Add content
for paragraph in content:
subprocess.run([
"officecli", "add", filename, "/",
"--type", "paragraph",
"--prop", f"text={paragraph}"
])
return filename
def get_cell_value(filename, cell):
"""Get cell value from Excel file."""
result = subprocess.run([
"officecli", "get", filename, cell, "--json"
], capture_output=True, text=True)
data = json.loads(result.stdout)
return data.get("attributes", {}).get("value")python
import subprocess
import json
def create_report(title, content):
"""使用OfficeCLI创建Word文档。"""
filename = f"{title}.docx"
# 创建文档
subprocess.run(["officecli", "create", filename])
# 添加标题
subprocess.run([
"officecli", "add", filename, "/",
"--type", "paragraph",
"--prop", f"text={title}",
"--prop", "style=Heading1"
])
# 添加内容
for paragraph in content:
subprocess.run([
"officecli", "add", filename, "/",
"--type", "paragraph",
"--prop", f"text={paragraph}"
])
return filename
def get_cell_value(filename, cell):
"""从Excel文件获取单元格值。"""
result = subprocess.run([
"officecli", "get", filename, cell, "--json"
], capture_output=True, text=True)
data = json.loads(result.stdout)
return data.get("attributes", {}).get("value")Usage
使用示例
create_report("Q1 Summary", [
"Revenue increased by 25%.",
"Customer satisfaction improved.",
"New product launch successful."
])
value = get_cell_value("budget.xlsx", "$Sheet1:B2")
print(f"Budget value: {value}")
undefinedcreate_report("Q1 Summary", [
"Revenue increased by 25%.",
"Customer satisfaction improved.",
"New product launch successful."
])
value = get_cell_value("budget.xlsx", "$Sheet1:B2")
print(f"Budget value: {value}")
undefinedNode.js Integration
Node.js集成
javascript
const { execSync } = require('child_process');
function createPresentation(title, slides) {
const filename = `${title}.pptx`;
// Create presentation
execSync(`officecli create "${filename}"`);
// Add slides
slides.forEach(slide => {
execSync(`officecli add "${filename}" / --type slide --prop title="${slide.title}"`);
if (slide.content) {
execSync(`officecli add "${filename}" '/slide[-1]' --type shape --prop text="${slide.content}" --prop x=2cm --prop y=5cm`);
}
});
return filename;
}
function viewAsHTML(filename) {
execSync(`officecli view "${filename}" html`);
}
// Usage
const slides = [
{ title: "Introduction", content: "Welcome to our presentation" },
{ title: "Main Points", content: "Key findings and results" },
{ title: "Conclusion", content: "Thank you" }
];
const file = createPresentation("meeting", slides);
viewAsHTML(file);javascript
const { execSync } = require('child_process');
function createPresentation(title, slides) {
const filename = `${title}.pptx`;
// 创建演示文稿
execSync(`officecli create "${filename}"`);
// 添加幻灯片
slides.forEach(slide => {
execSync(`officecli add "${filename}" / --type slide --prop title="${slide.title}"`);
if (slide.content) {
execSync(`officecli add "${filename}" '/slide[-1]' --type shape --prop text="${slide.content}" --prop x=2cm --prop y=5cm`);
}
});
return filename;
}
function viewAsHTML(filename) {
execSync(`officecli view "${filename}" html`);
}
// 使用示例
const slides = [
{ title: "Introduction", content: "Welcome to our presentation" },
{ title: "Main Points", content: "Key findings and results" },
{ title: "Conclusion", content: "Thank you" }
];
const file = createPresentation("meeting", slides);
viewAsHTML(file);Troubleshooting
故障排除
Binary not found after installation
安装后找不到二进制文件
bash
undefinedbash
undefinedCheck if binary is in PATH
检查二进制文件是否在PATH中
which officecli
which officecli
If not, run install again
如果不在,重新运行安装命令
officecli install
officecli install
Or manually add to PATH
或者手动添加到PATH
export PATH="$PATH:$HOME/.officecli/bin"
undefinedexport PATH="$PATH:$HOME/.officecli/bin"
undefinedFile not opening in Office
文件无法在Office中打开
bash
undefinedbash
undefinedVerify file is valid
验证文件是否有效
officecli view document.docx outline
officecli view document.docx outline
Check file wasn't corrupted
检查文件是否损坏
file document.docx
file document.docx
Should show: "Microsoft Word 2007+"
应显示:"Microsoft Word 2007+"
undefinedundefinedPreview not refreshing in watch mode
监听模式下预览不刷新
bash
undefinedbash
undefinedEnsure watch server is running
确保监听服务器正在运行
officecli watch document.docx
officecli watch document.docx
Check if port is blocked
检查端口是否被占用
officecli watch document.docx --port 8081
officecli watch document.docx --port 8081
Clear browser cache or hard refresh (Ctrl+Shift+R / Cmd+Shift+R)
清除浏览器缓存或强制刷新(Ctrl+Shift+R / Cmd+Shift+R)
undefinedundefinedPermission denied errors
权限拒绝错误
bash
undefinedbash
undefinedEnsure file isn't open in another program
确保文件未在其他程序中打开
Close Office/LibreOffice/other editors
关闭Office/LibreOffice或其他编辑器
Check file permissions
检查文件权限
ls -l document.docx
chmod 644 document.docx
undefinedls -l document.docx
chmod 644 document.docx
undefinedInvalid path errors
无效路径错误
bash
undefinedbash
undefinedVerify document structure first
先验证文档结构
officecli view document.docx outline
officecli view document.docx outline
Paths are 1-indexed: /paragraph[1], /slide[1]
路径从1开始计数:/paragraph[1], /slide[1]
Use --json to see exact paths
使用--json查看确切路径
officecli get document.docx / --json
undefinedofficecli get document.docx / --json
undefinedFormula not calculating in Excel
Excel公式未计算
bash
undefinedbash
undefinedOfficeCLI auto-evaluates 150+ functions
OfficeCLI自动计算150+种函数
Unsupported functions show #NAME? error
不支持的函数会显示#NAME?错误
Check formula syntax:
检查公式语法:
officecli get spreadsheet.xlsx '$Sheet1:A1' --json
undefinedofficecli get spreadsheet.xlsx '$Sheet1:A1' --json
undefinedRTL text not rendering correctly
RTL文本渲染不正确
bash
undefinedbash
undefinedSet direction property
设置方向属性
officecli set document.docx '/paragraph[1]'
--prop direction=rtl
--prop lang.cs=ar-SA
--prop direction=rtl
--prop lang.cs=ar-SA
officecli set document.docx '/paragraph[1]'
--prop direction=rtl
--prop lang.cs=ar-SA
--prop direction=rtl
--prop lang.cs=ar-SA
For complex scripts, set appropriate font
对于复杂脚本,设置合适的字体
officecli set document.docx '/paragraph[1]'
--prop font.cs="Arial Unicode MS"
--prop font.cs="Arial Unicode MS"
undefinedofficecli set document.docx '/paragraph[1]'
--prop font.cs="Arial Unicode MS"
--prop font.cs="Arial Unicode MS"
undefinedImage not appearing
图片不显示
bash
undefinedbash
undefinedCheck image path is correct and file exists
检查图片路径是否正确且文件存在
ls -l image.png
ls -l image.png
Ensure image format is supported (PNG/JPG/GIF/SVG)
确保图片格式受支持(PNG/JPG/GIF/SVG)
file image.png
file image.png
Use absolute path if relative path fails
如果相对路径失败,使用绝对路径
officecli add doc.docx / --type picture --prop src=/full/path/to/image.png
undefinedofficecli add doc.docx / --type picture --prop src=/full/path/to/image.png
undefinedConfiguration
配置
OfficeCLI is designed to work out-of-the-box with no configuration needed. All settings are passed as command-line flags.
Common flags:
- - Output as JSON
--json - - Custom port for watch server (default: 26315)
--port PORT - - Set element properties
--prop key=value
OfficeCLI开箱即用,无需额外配置。所有设置都通过命令行标志传递。
常见标志:
- - 以JSON格式输出
--json - - 自定义监听服务器端口(默认:26315)
--port PORT - - 设置元素属性
--prop key=value
Documentation
文档
- Wiki: https://github.com/iOfficeAI/OfficeCLI/wiki
- Word Reference: https://github.com/iOfficeAI/OfficeCLI/wiki/word-paragraph
- Excel Reference: https://github.com/iOfficeAI/OfficeCLI/wiki/excel-cell
- PowerPoint Reference: https://github.com/iOfficeAI/OfficeCLI/wiki/ppt-slide
- i18n Support: https://github.com/iOfficeAI/OfficeCLI/wiki/i18n
- GitHub: https://github.com/iOfficeAI/OfficeCLI
- Discord: https://discord.gg/2QAwJn7Egx
- Wiki: https://github.com/iOfficeAI/OfficeCLI/wiki
- Word参考: https://github.com/iOfficeAI/OfficeCLI/wiki/word-paragraph
- Excel参考: https://github.com/iOfficeAI/OfficeCLI/wiki/excel-cell
- PowerPoint参考: https://github.com/iOfficeAI/OfficeCLI/wiki/ppt-slide
- 国际化支持: https://github.com/iOfficeAI/OfficeCLI/wiki/i18n
- GitHub: https://github.com/iOfficeAI/OfficeCLI
- Discord: https://discord.gg/2QAwJn7Egx
Key Concepts
核心概念
- XPath-like addressing: All elements use path notation (,
/paragraph[1],$Sheet1:A1)/slide[1]/shape[2] - Unified interface: Same ,
add,set,get,removeverbs across all formatsview - Live preview: command provides real-time browser preview with auto-refresh
watch - No dependencies: Single binary, no Office installation needed
- AI-first design: Commands optimized for LLM generation and automation
- Format preservation: Edit documents without breaking complex formatting
- Rich i18n: Full RTL support, per-script fonts, locale-aware rendering
When helping users with OfficeCLI, focus on the unified command structure and path-based addressing. The same patterns work across Word, Excel, and PowerPoint with format-specific properties.
- 类XPath寻址: 所有元素使用路径表示法(,
/paragraph[1],$Sheet1:A1)/slide[1]/shape[2] - 统一界面: 所有格式都使用相同的、
add、set、get、remove命令view - 实时预览: 命令提供浏览器实时预览并自动刷新
watch - 无依赖: 独立二进制文件,无需安装Office
- AI优先设计: 命令针对LLM生成和自动化进行优化
- 格式保留: 编辑文档时不会破坏复杂格式
- 丰富的国际化: 完整的RTL支持、按脚本设置字体、区域感知渲染
在为用户提供OfficeCLI帮助时,重点关注统一的命令结构和基于路径的寻址方式。相同的模式适用于Word、Excel和PowerPoint,仅需调整格式特定的属性。