From marketing-agent
Use when generating Excel workbooks (.xlsx). Pandas + openpyxl patterns for multiple sheets, number formats, freeze panes, formulas.
How this skill is triggered — by the user, by Claude, or both
Slash command
/marketing-agent:documents-xlsx-skillThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate downloadable \`.xlsx\` files for structured tabular output that CSV cannot express: multiple sheets, formulas, formatted cells, frozen headers, currency / percent / date number formats. If the user says "Excel" — produce \`.xlsx\`, not CSV.
Generate downloadable `.xlsx` files for structured tabular output that CSV cannot express: multiple sheets, formulas, formatted cells, frozen headers, currency / percent / date number formats. If the user says "Excel" — produce `.xlsx`, not CSV.
Pick xlsx if ANY of these are true:
Pick csv if the output is a single flat table meant for pipeline interchange, raw data dump, or when the file will be read programmatically, not humans.
When in doubt → xlsx.
```python import pandas as pd df = pd.DataFrame(rows) df.to_excel(f'{WORKSPACE}/campaign-report.xlsx', index=False, sheet_name='Summary', engine='openpyxl') ```
`index=False` is almost always right. Omitting it writes the pandas index as a leading column and confuses users.
```python import pandas as pd with pd.ExcelWriter(f'{WORKSPACE}/performance.xlsx', engine='openpyxl') as w: summary_df.to_excel(w, sheet_name='Summary', index=False) campaigns_df.to_excel(w, sheet_name='Campaign Detail', index=False) weekly_df.to_excel(w, sheet_name='Weekly Trend', index=False) ```
Use when cell colors, number formats, frozen headers, custom column widths, or formulas are required.
```python from openpyxl import Workbook from openpyxl.styles import Font, PatternFill, Alignment from openpyxl.utils import get_column_letter
wb = Workbook() ws = wb.active ws.title = 'Summary'
headers = ['Campaign', 'Spend', 'Revenue', 'ROAS'] ws.append(headers)
header_font = Font(bold=True, color='FFFFFF') header_fill = PatternFill('solid', fgColor='006E78') for cell in ws[1]: cell.font = header_font cell.fill = header_fill cell.alignment = Alignment(horizontal='center')
for row in rows: ws.append([row['campaign'], row['spend'], row['revenue'], row['roas']])
for r in range(2, ws.max_row + 1): ws.cell(row=r, column=2).number_format = '"$"#,##0.00' ws.cell(row=r, column=3).number_format = '"$"#,##0.00' ws.cell(row=r, column=4).number_format = '0.00"x"'
ws.freeze_panes = 'A2' ws.column_dimensions['A'].width = 32 ws.column_dimensions['B'].width = 14 ws.column_dimensions['C'].width = 14 ws.column_dimensions['D'].width = 10
wb.save(f'{WORKSPACE}/performance.xlsx') ```
Formulas — write as strings starting with `=`:
```python ws['D2'] = '=C2/B2' # openpyxl does NOT evaluate; Excel computes on open ```
For pre-computed totals (recommended when the file must display a numeric value without being opened in Excel first), calculate the total in pandas and write the literal number — not a formula.
```python import pandas as pd from openpyxl import load_workbook from openpyxl.styles import Font, PatternFill, Alignment
df_summary = pd.DataFrame([ {'Metric': 'Total Spend', 'Value': total_spend}, {'Metric': 'Total Revenue', 'Value': total_revenue}, {'Metric': 'Overall ROAS', 'Value': overall_roas}, ]) df_campaigns = campaigns_df # from earlier analysis df_weekly = weekly_df
out = f'{WORKSPACE}/ads-performance-report.xlsx' with pd.ExcelWriter(out, engine='openpyxl') as w: df_summary.to_excel(w, sheet_name='Overview', index=False) df_campaigns.to_excel(w, sheet_name='Campaign Breakdown', index=False) df_weekly.to_excel(w, sheet_name='Weekly Trend', index=False)
wb = load_workbook(out) for sheet_name in wb.sheetnames: ws = wb[sheet_name] # Header styling for cell in ws[1]: cell.font = Font(bold=True, color='FFFFFF') cell.fill = PatternFill('solid', fgColor='006E78') cell.alignment = Alignment(horizontal='center') ws.freeze_panes = 'A2' # Auto-widen based on max content length per column for col_idx, col_cells in enumerate(ws.columns, start=1): max_len = max((len(str(c.value)) for c in col_cells if c.value is not None), default=10) ws.column_dimensions[ws.cell(row=1, column=col_idx).column_letter].width = min(max_len + 2, 40)
wb.save(out) ```
npx claudepluginhub gomarble-ai/marketing-agent --plugin marketing-agentGuides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.