Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
This skill enables programmatic creation, editing, and manipulation of Microsoft Word (.docx) documents using the library. Create professional documents with proper formatting, styles, tables, and images without manual editing.
python-docx
How to Use
Describe what you want to create or modify in a Word document
Provide any source content (text, data, images)
I'll generate python-docx code and execute it
Example prompts:
"Create a professional report with title, headings, and a table"
"Add a header and footer to this document"
"Generate a contract document with placeholders"
"Convert this markdown content to a styled Word document"
Domain Knowledge
python-docx Fundamentals
from docx import Document
from docx.shared import Inches, Pt, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.style import WD_STYLE_TYPE
# Create new document
doc = Document()
# Or open existing
doc = Document('existing.docx')
# Add image with size
doc.add_picture('image.png', width=Inches(4))
# Add to specific paragraph
para = doc.add_paragraph()
run = para.add_run()
run.add_picture('logo.png', width=Inches(1.5))
Formatting
Paragraph Formatting
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.shared import Pt, Inches
para = doc.add_paragraph('Formatted text')
para.alignment = WD_ALIGN_PARAGRAPH.CENTER
para.paragraph_format.line_spacing = 1.5
para.paragraph_format.space_after = Pt(12)
para.paragraph_format.first_line_indent = Inches(0.5)
Structure First: Plan document hierarchy before coding
Use Styles: Consistent formatting via styles, not manual formatting
Save Often: Call doc.save() periodically for large documents
Handle Errors: Check file existence before opening
Clean Up: Remove template placeholders after filling
Common Patterns
Report Template
defcreate_report(title, sections):
doc = Document()
doc.add_heading(title, 0)
doc.add_paragraph(f'Generated: {datetime.now()}')
for section_title, content in sections.items():
doc.add_heading(section_title, 1)
doc.add_paragraph(content)
return doc
Table from Data
defadd_data_table(doc, headers, rows):
table = doc.add_table(rows=1, cols=len(headers))
table.style = 'Table Grid'# Headersfor i, header inenumerate(headers):
table.rows[0].cells[i].text = header
table.rows[0].cells[i].paragraphs[0].runs[0].bold = True# Data rowsfor row_data in rows:
row = table.add_row()
for i, value inenumerate(row_data):
row.cells[i].text = str(value)
return table
Mail Merge Pattern
deffill_template(template_path, replacements):
doc = Document(template_path)
for para in doc.paragraphs:
for key, value in replacements.items():
iff'{{{key}}}'in para.text:
para.text = para.text.replace(f'{{{key}}}', value)
return doc
Examples
Example 1: Create a Business Letter
from docx import Document
from docx.shared import Inches, Pt
from docx.enum.text import WD_ALIGN_PARAGRAPH
from datetime import datetime
doc = Document()
# Letterhead
doc.add_paragraph('ACME Corporation')
doc.add_paragraph('123 Business Ave, Suite 100')
doc.add_paragraph('New York, NY 10001')
doc.add_paragraph()
# Date
doc.add_paragraph(datetime.now().strftime('%B %d, %Y'))
doc.add_paragraph()
# Recipient
doc.add_paragraph('Mr. John Smith')
doc.add_paragraph('XYZ Company')
doc.add_paragraph('456 Industry Blvd')
doc.add_paragraph('Chicago, IL 60601')
doc.add_paragraph()
# Salutation
doc.add_paragraph('Dear Mr. Smith,')
doc.add_paragraph()
# Body
body = """We are pleased to inform you that your proposal has been accepted...
[Letter body continues...]
Thank you for your continued partnership."""for para_text in body.split('\n\n'):
doc.add_paragraph(para_text)
doc.add_paragraph()
doc.add_paragraph('Sincerely,')
doc.add_paragraph()
doc.add_paragraph()
doc.add_paragraph('Jane Doe')
doc.add_paragraph('CEO, ACME Corporation')
doc.save('business_letter.docx')
Example 2: Create a Report with Table
from docx import Document
from docx.shared import Inches
doc = Document()
doc.add_heading('Q4 Sales Report', 0)
# Executive Summary
doc.add_heading('Executive Summary', 1)
doc.add_paragraph('Q4 2024 showed strong growth across all regions...')
# Sales Table
doc.add_heading('Regional Performance', 1)
table = doc.add_table(rows=1, cols=4)
table.style = 'Medium Grid 1 Accent 1'
headers = ['Region', 'Q3 Sales', 'Q4 Sales', 'Growth']
for i, header inenumerate(headers):
table.rows[0].cells[i].text = header
data = [
['North America', '$1.2M', '$1.5M', '+25%'],
['Europe', '$800K', '$950K', '+18%'],
['Asia Pacific', '$600K', '$750K', '+25%'],
]
for row_data in data:
row = table.add_row()
for i, value inenumerate(row_data):
row.cells[i].text = value
doc.save('sales_report.docx')
Limitations
Cannot execute macros or VBA code
Complex templates may lose some formatting
Limited support for advanced features (SmartArt, Charts)