name: office-editor description: Create or modify Word (.docx), Excel (.xlsx), and PowerPoint (.pptx) files. Use when the user mentions Office, Word, Excel, PowerPoint, docx, xlsx, pptx, spreadsheets, presentations, or document export. Check dependencies first, and if a core library is missing, report it directly instead of installing anything automatically. user-invocable: true metadata: {"openclaw":{"emoji":"📄"}}
Use this skill for .docx, .xlsx, and .pptx files. Identify the file type first, check the required dependencies next, and then decide whether to create a new file or modify an existing one.
python-docx, Excel uses openpyxl, and PowerPoint uses python-pptx.pip, pip3, python -m pip, sudo, or similar install commands automatically.references/ when an advanced API is needed. Do not load every reference file into context at once.python-docx: for Word documents.openpyxl: for Excel workbooks.小葱技能站7w4.net每天更新,海量AI技能等你发现。
python-pptx: for PowerPoint presentations.pandas: only needed when converting between DataFrames and Excel.pillow: only needed when inserting images into Excel.Use a read-only import check like this. If the check fails, stop implementation and report the missing package(s) directly.
import importlib
PACKAGE_MAP = {
"docx": "python-docx",
"openpyxl": "openpyxl",
"pptx": "python-pptx",
"pandas": "pandas",
"PIL": "pillow",
}
missing = []
for module_name, package_name in PACKAGE_MAP.items():
try:
importlib.import_module(module_name)
except ModuleNotFoundError:
missing.append(package_name)
print(missing)
Choose what to check based on the task:
.docx tasks: check docx.xlsx tasks: check openpyxl.pptx tasks: check pptxpandasPILUse python-docx for .docx files.
from docx import Document
document = Document()
document.add_heading("Document Title", level=1)
document.add_paragraph("This is a paragraph.")
document.save("new_doc.docx")
from docx import Document
document = Document("existing_doc.docx")
document.add_paragraph("Appended content")
document.save("updated_doc.docx")
{baseDir}/references/docx_api_summary.md{baseDir}/scripts/create_basic_doc.py{baseDir}/scripts/edit_existing_doc.pyUse openpyxl for .xlsx files.
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws.title = "Data"
ws["A1"] = "Hello"
ws.append(["Data 1", "Data 2", "Data 3"])
wb.save("new_workbook.xlsx")
from openpyxl import load_workbook
wb = load_workbook("existing_workbook.xlsx")
ws = wb["Sheet1"]
ws["A1"] = "Updated value"
wb.save("updated_workbook.xlsx")
{baseDir}/scripts/create_basic_workbook.py{baseDir}/references/xlsx_charts.md{baseDir}/references/xlsx_features.md{baseDir}/references/xlsx_pandas.mdUse python-pptx for .pptx files.
from pptx import Presentation
prs = Presentation()
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "Slide Title"
slide.placeholders[1].text = "This is the content placeholder."
prs.save("new_presentation.pptx")
from pptx import Presentation
prs = Presentation("existing_presentation.pptx")
slide = prs.slides.add_slide(prs.slide_layouts[1])
slide.shapes.title.text = "New Slide"
slide.placeholders[1].text = "Additional content"
prs.save("updated_presentation.pptx")
{baseDir}/references/pptx_api_reference.md{baseDir}/references/pptx_chart_guide.md{baseDir}/scripts/create_presentation.py{baseDir}/scripts/create_basic_doc.py{baseDir}/scripts/edit_existing_doc.py{baseDir}/scripts/create_basic_workbook.py{baseDir}/references/xlsx_charts.md or {baseDir}/references/xlsx_features.md firstpandas is available, then read {baseDir}/references/xlsx_pandas.md{baseDir}/scripts/create_presentation.py{baseDir}/references/pptx_chart_guide.md firstreport.docx, budget.xlsx, or deck.pptx.updated_*.ext to avoid accidental overwrites.这个Skill能帮你创建和编辑Word文档、Excel表格和PowerPoint演示文稿。整体质量较好,结构清晰易读,提供了足够的使用规则和代码示例,参考文档也很全面。美中不足的是,某些高级功能场景的示例稍显单薄,如果需要做复杂的格式或批量处理,可能需要自己摸索更多细节。总体而言,这是一个实用且可靠的办公文档处理技能。