<< All versions
Simple PDFs — use
Complex PDFs with tables/images — use
PowerPoint (PPTX) Creation — use
Excel (XLSX) Creation — use
Charts and Visualizations — use
Skill v1.0.0
currentAutomated scan100/100bingreeky/jit/skill-office-process
──Details
PublishedOctober 26, 2026 at 03:36 AM
Content Hashsha256:6f1372e99ed1e4ad...
Git SHAababa06c2f54
──Files
Files (1 file, 6.0 KB)
SKILL.md6.0 KBactive
SKILL.md · 208 lines · 6.0 KB
version: "1.0.0"
Office Document Processing Skill
When creating or manipulating office documents (PDF, PPTX, XLSX) or generating charts, use the execute_code tool with the following Python libraries and patterns.
PDF Creation
Simple PDFs — use fpdf2
python
from fpdf import FPDFpdf = FPDF()pdf.add_page()pdf.set_font("Helvetica", size=16)pdf.cell(text="Title", new_x="LMARGIN", new_y="NEXT", align="C")pdf.set_font("Helvetica", size=12)pdf.multi_cell(w=0, text="Body text here...")pdf.output("output.pdf")
Complex PDFs with tables/images — use reportlab
python
from reportlab.lib.pagesizes import letterfrom reportlab.platypus import SimpleDocTemplate, Paragraph, Table, TableStyle, Imagefrom reportlab.lib.styles import getSampleStyleSheetfrom reportlab.lib import colorsdoc = SimpleDocTemplate("report.pdf", pagesize=letter)styles = getSampleStyleSheet()elements = []elements.append(Paragraph("Report Title", styles['Title']))elements.append(Paragraph("Body text...", styles['Normal']))# Tabledata = [["Header1", "Header2"], ["Row1Col1", "Row1Col2"]]table = Table(data)table.setStyle(TableStyle([('BACKGROUND', (0, 0), (-1, 0), colors.grey),('GRID', (0, 0), (-1, -1), 1, colors.black),]))elements.append(table)# Include an imageelements.append(Image("chart.png", width=400, height=300))doc.build(elements)
PowerPoint (PPTX) Creation — use python-pptx
python
from pptx import Presentationfrom pptx.util import Inches, Ptfrom pptx.enum.text import PP_ALIGNprs = Presentation()# Title slideslide = prs.slides.add_slide(prs.slide_layouts[0])slide.shapes.title.text = "Presentation Title"slide.placeholders[1].text = "Subtitle"# Content slide with bullet pointsslide = prs.slides.add_slide(prs.slide_layouts[1])slide.shapes.title.text = "Key Points"body = slide.placeholders[1]body.text = "First point"for point in ["Second point", "Third point"]:p = body.text_frame.add_paragraph()p.text = pointp.level = 0# Slide with imageslide = prs.slides.add_slide(prs.slide_layouts[5]) # blank layoutslide.shapes.add_picture("chart.png", Inches(1), Inches(1), width=Inches(8))# Slide with tableslide = prs.slides.add_slide(prs.slide_layouts[5])table = slide.shapes.add_table(rows=3, cols=3, left=Inches(1), top=Inches(1.5), width=Inches(8), height=Inches(2)).tabletable.cell(0, 0).text = "Header"prs.save("output.pptx")
Excel (XLSX) Creation — use openpyxl
python
from openpyxl import Workbookfrom openpyxl.styles import Font, PatternFill, Alignment, Border, Sidefrom openpyxl.chart import BarChart, Referencefrom openpyxl.utils import get_column_letterwb = Workbook()ws = wb.activews.title = "Data"# Headers with stylingheaders = ["Name", "Value", "Category"]header_fill = PatternFill(start_color="4472C4", end_color="4472C4", fill_type="solid")header_font = Font(color="FFFFFF", bold=True)for col, header in enumerate(headers, 1):cell = ws.cell(row=1, column=col, value=header)cell.fill = header_fillcell.font = header_font# Data rowsdata = [("Item A", 100, "Type 1"), ("Item B", 200, "Type 2")]for row_idx, row_data in enumerate(data, 2):for col_idx, value in enumerate(row_data, 1):ws.cell(row=row_idx, column=col_idx, value=value)# Formulas — IMPORTANT: always use Excel formulas, not hardcoded valuesws.cell(row=4, column=2, value="=SUM(B2:B3)")ws.cell(row=4, column=1, value="Total")# Column widthsfor col in range(1, 4):ws.column_dimensions[get_column_letter(col)].width = 15# Add chartchart = BarChart()chart.title = "Values by Category"data_ref = Reference(ws, min_col=2, min_row=1, max_row=3)cats_ref = Reference(ws, min_col=1, min_row=2, max_row=3)chart.add_data(data_ref, titles_from_data=True)chart.set_categories(cats_ref)ws.add_chart(chart, "E2")wb.save("output.xlsx")
Charts and Visualizations — use matplotlib
python
import matplotlibmatplotlib.use('Agg') # Non-interactive backend — ALWAYS set thisimport matplotlib.pyplot as pltimport numpy as np# Line chartfig, ax = plt.subplots(figsize=(10, 6))x = np.arange(2020, 2026)y = [100, 120, 115, 140, 160, 180]ax.plot(x, y, marker='o', linewidth=2, label='Revenue')ax.set_xlabel('Year')ax.set_ylabel('Revenue ($M)')ax.set_title('Annual Revenue Trend')ax.legend()ax.grid(True, alpha=0.3)plt.tight_layout()plt.savefig('chart.png', dpi=150, bbox_inches='tight')plt.close()# Bar chartfig, ax = plt.subplots(figsize=(10, 6))categories = ['A', 'B', 'C', 'D']values = [25, 40, 30, 55]ax.bar(categories, values, color=['#4472C4', '#ED7D31', '#A5A5A5', '#FFC000'])ax.set_title('Category Comparison')plt.savefig('bar_chart.png', dpi=150, bbox_inches='tight')plt.close()# Pie chartfig, ax = plt.subplots(figsize=(8, 8))sizes = [35, 25, 20, 20]labels = ['Category A', 'Category B', 'Category C', 'Category D']ax.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)ax.set_title('Distribution')plt.savefig('pie_chart.png', dpi=150, bbox_inches='tight')plt.close()
Reading Existing Documents
Read PDF
python
import pdfminer.high_leveltext = pdfminer.high_level.extract_text("input.pdf")print(text)
Read Excel
python
import openpyxlwb = openpyxl.load_workbook("input.xlsx", data_only=True)ws = wb.activefor row in ws.iter_rows(values_only=True):print(row)
Read PowerPoint
python
from pptx import Presentationprs = Presentation("input.pptx")for slide in prs.slides:for shape in slide.shapes:if shape.has_text_frame:print(shape.text_frame.text)
Key Reminders
- Always use
matplotlib.use('Agg')before importing pyplot (no display server available) - For Excel: use formulas (
=SUM(...)) not hardcoded calculated values - For charts embedded in reports: save as PNG first, then embed via reportlab or python-pptx
- For Chinese text in matplotlib: set
plt.rcParams['font.sans-serif'] = ['SimHei']or use a CJK font - Print file paths of created files so the observation shows what was produced