闲社服务运行正常AI智能体自动化平台
o

办公文档处理

技能标识:office-docs

Generate and manipulate office documents (PDF, DOCX, XLSX, PPTX) for professional reports, presentations, and data exports. Use when: (1) Creating PDFs from text/images, (2) Generating Word documents, (3) Creating Excel spreadsheets with formulas, (4) Building PowerPoint presentations, (5) Extracting content from office documents.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 1.0.0
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

办公文档处理

Office Docs - 专业文档生成

用于创建和操作办公文档的综合技能。支持PDF、DOCX、XLSX和PPTX格式。

快速参考

格式创建读取编辑
PDFfpdf, reportlabpdfplumber, pymupdfpypdf
DOCX
python-docx | python-docx | python-docx | | XLSX | openpyxl, pandas | openpyxl, pandas | openpyxl | | PPTX | python-pptx | python-pptx | python-pptx |

PDF 操作

安装

bash
pip install fpdf reportlab pdfplumber pymupdf pypdf

创建PDF

python
from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.set_font(Helvetica, size=12)
pdf.cell(0, 10, Hello World, ln=True)
pdf.output(document.pdf)

创建带图片的PDF

python
from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.image(photo.jpg, x=10, y=10, w=100)
pdf.output(with_image.pdf)

从PDF提取文本

python
import pdfplumber

with pdfplumber.open(document.pdf) as pdf:
for page in pdf.pages:
print(page.extract_text())

合并PDF

python
from pypdf import PdfMerger

merger = PdfMerger()
merger.append(file1.pdf)
merger.append(file2.pdf)
merger.write(merged.pdf)
merger.close()

拆分PDF

python
from pypdf import PdfReader, PdfWriter

reader = PdfReader(document.pdf)
writer = PdfWriter()

for i in range(0, 5): # 前5页
writer.add_page(reader.pages[i])

with open(split.pdf, wb) as f:
writer.write(f)



DOCX (Word) 操作

安装

bash
pip install python-docx

创建文档

python
from docx import Document

doc = Document()
doc.add_heading(报告标题, level=0)
doc.add_paragraph(这是一个段落。)
doc.add_paragraph(加粗文本, style=Intense Quote)
doc.save(report.docx)

添加表格

python
from docx import Document

doc = Document()
table = doc.add_table(rows=3, cols=2)
table.style = Table Grid

表头行

hdr_cells = table.rows[0].cells hdr_cells[0].text = 名称 hdr_cells[1].text = 数值

数据行

row = table.rows[1].cells row[0].text = 收入 row[1].text = $1,000,000

doc.save(table.docx)

添加图片

python
from docx import Document
from docx.shared import Inches

doc = Document()
doc.add_picture(chart.png, width=Inches(5))
doc.save(with_image.docx)

读取文档

python
from docx import Document

doc = Document(report.docx)
for para in doc.paragraphs:
print(para.text)

for table in doc.tables:
for row in table.rows:
for cell in row.cells:
print(cell.text)

添加项目符号列表

python
from docx import Document

doc = Document()
doc.add_paragraph(项目:, style=List Bullet)
doc.add_paragraph(第一项, style=List Bullet)
doc.add_paragraph(第二项, style=List Bullet)
doc.save(bullets.docx)



XLSX (Excel) 操作

安装

bash
pip install openpyxl pandas xlsxwriter

创建工作簿

python
from openpyxl import Workbook

wb = Workbook()
ws = wb.active
ws.title = Sheet1

表头

ws[A1] = 名称 ws[B1] = 数值

数据

ws[A2] = 收入 ws[B2] = 1000000

公式

ws[A3] = 总计 ws[B3] = =SUM(B2:B2)

wb.save(data.xlsx)

使用Pandas创建

python
import pandas as pd

df = pd.DataFrame({
名称: [Alice, Bob, Charlie],
分数: [85, 92, 78]
})

df.to_excel(scores.xlsx, index=False)

添加图表

python
from openpyxl import Workbook
from openpyxl.chart import BarChart, Reference

wb = Workbook()
ws = wb.active

数据

ws[A1] = 月份 ws[B1] = 销售额 data = [(一月, 100), (二月, 150), (三月, 200)] for i, (month, sales) in enumerate(data, 2): ws[fA{i}] = month ws[fB{i}] = sales

图表

chart = BarChart() chart.adddata(Reference(ws, mincol=2, minrow=1, maxrow=4)) chart.setcategories(Reference(ws, mincol=1, minrow=2, maxrow=4)) chart.title = 月度销售额 ws.add_chart(chart, D1)

wb.save(chart.xlsx)

读取工作簿

python
from openpyxl import load_workbook

wb = load_workbook(data.xlsx)
ws = wb.active

for row in ws.iterrows(valuesonly=True):
print(row)

格式化单元格

python
from openpyxl.styles import Font, PatternFill, Alignment
from openpyxl import Workbook

wb = Workbook()
ws = wb.active

加粗表头

ws[A1] = 表头 ws[A1].font = Font(bold=True, size=14)

背景颜色

ws[A1].fill = PatternFill(startcolor=4472C4, filltype=solid) ws[A1].font = Font(color=FFFFFF, bold=True)

居中对齐

ws[A1].alignment = Alignment(horizontal=center)

wb.save(formatted.xlsx)



PPTX (PowerPoint) 操作

安装

bash
pip install python-pptx

创建演示文稿

python
from pptx import Presentation
from pptx.util import Inches, Pt

prs = Presentation()

标题幻灯片

slidelayout = prs.slidelayouts[0] slide = prs.slides.addslide(slidelayout) title = slide.shapes.title subtitle = slide.placeholders[1] title.text = 演示文稿标题 subtitle.text = 此处为副标题

prs.save(presentation.pptx)

添加项目符号幻灯片

python
from pptx import Presentation
from pptx.util import Inches

prs = Presentation()
slidelayout = prs.slidelayouts[1] # 标题和内容
slide = prs.slides.addslide(slidelayout)

title = slide.shapes.title
title.text = 关键点

body = slide.placeholders[1]
tf = body.text_frame
tf.text = 第一点

p = tf.add_paragraph()
p.text = 第二点
p.level = 1 # 缩进

prs.save(bullets.pptx)

添加图片

python
from pptx import Presentation
from pptx.util import Inches

prs = Presentation()
slidelayout = prs.slidelayouts[5] # 空白
slide = prs.slides.addslide(slidelayout)

slide.shapes.add_picture(chart.png, Inches(1), Inches(1), width=Inches(8))

prs.save(with_image.pptx)

添加表格

python
from pptx import Presentation
from pptx.util import Inches

prs = Presentation()
slidelayout = prs.slidelayouts[5] # 空白
slide = prs.slides.addslide(slidelayout)

rows, cols = 4, 3
table = slide.shapes.add_table(rows, cols, Inches(1), Inches(1), Inches(8), Inches(3)).table

设置表头

table.cell(0, 0).text = 名称 table.cell(0, 1).text = Q1 table.cell(0, 2).text = Q2

设置数据

table.cell(1, 0).text = Alice table.cell(1,

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 pls-office-docs-1776321322 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 pls-office-docs-1776321322 技能

通过命令行安装

skillhub install pls-office-docs-1776321322

下载

⬇ 下载 office-docs v1.0.0(免费)

文件大小: 3.27 KB | 发布时间: 2026-4-16 15:54

v1.0.0 最新 2026-4-16 15:54
Initial release of office-docs: generate, read, and edit major office document formats (PDF, DOCX, XLSX, PPTX).

- Generate PDFs (from text and images), merge and split PDFs, extract PDF text.
- Create, read, and edit Word documents, including tables, images, and bullet lists.
- Build and manipulate Excel files with formulas, charts, pandas integration, and cell formatting.
- Create and edit PowerPoint presentations, including slides with tables, bullet points, and images.
- Designed for professional report generation, data export, and presentation automation.
返回顶部