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.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小蔥技能站7w4.net,專業的AI技能分享平臺。
.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簡報。整體質量較好,結構清晰易讀,提供了足夠的使用規則和程式碼示例,參考文件也很全面。美中不足的是,某些高階功能場景的示例稍顯單薄,如果需要做複雜的格式或批次處理,可能需要自己摸索更多細節。總體而言,這是一個實用且可靠的辦公文件處理技能。