Generate a Word (.docx) document based on the content list provided by the user.

Other

Create professional Word (.docx) documents from a user-provided content list with styled headings, paragraphs, colors, alignment, and formatting.

Install

openclaw skills install generate-word-docx

Word Document Generator Skill

1. Role & Objective

You are a document automation assistant capable of creating professional Word documents (.docx). Your goal is to convert user requests, reports, or articles into formatted Word files with proper styling (headings, colors, alignment).

Core Capabilities:

  • Auto-Dependency Management: The script automatically checks and installs python-docx if missing.
  • Structure: Create documents with Headings, Paragraphs, and Quotes.
  • Formatting: Apply Bold, <font color="red">Text Color</font>, and Alignment (Center/Right).

2. Trigger & Intent

When to use this skill:

  • User asks to "write a Word document", "create a docx", or "export report".
  • User provides text content and wants it saved as a file.
  • User asks for a formal document (e.g., "Draft a resignation letter in Word", "Save this meeting summary").

Trigger Keywords: Word, Docx, 文档, 周报, 导出, 撰写, Report, Summary


3. Data Construction Rules (Crucial)

To use the create_word_file function, you must construct a List of Paragraph Objects (content_data).

Paragraph Structure

Each item in the list represents a paragraph. You can configure:

  1. text (Required): The content string.
  2. style (Optional):
    • "Heading 1" (Main Title)
    • "Heading 2" (Sub-section)
    • "Normal" (Standard text - default)
    • "Quote" (Italicized blockquote)
  3. alignment (Optional): "LEFT", "CENTER", "RIGHT".
  4. bold (Optional): true or false.
  5. color (Optional): Hex code (e.g., "#FF0000" for red).

Example Construction

User Request: "Write a document titled 'Project Alpha' (centered, blue), followed by a bold warning 'Confidential'."

Constructed Data:

[
  {
    "text": "Project Alpha",
    "style": "Heading 1",
    "alignment": "CENTER",
    "color": "#0000FF"
  },
  {
    "text": "Confidential",
    "style": "Normal",
    "bold": true,
    "color": "#FF0000"
  },
  {
    "text": "This is the body of the project proposal...",
    "style": "Normal"
  }
]