home / skills / ntaksh42 / agents / excel-processor

excel-processor skill

/.claude/skills/excel-processor

This skill automates Excel file creation, editing, and analysis, generating formulas and charts to streamline spreadsheet work.

npx playbooks add skill ntaksh42/agents --skill excel-processor

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
3.9 KB
---
name: excel-processor
description: Process Excel files with data manipulation, formula generation, and chart creation. Use when working with spreadsheets or Excel data.
---

# Excel Processor Skill

Excelファイルの作成、編集、解析を行うスキルです。

## 概要

Excelの読み書き、数式、グラフ、スタイル設定を自動化します。

## 主な機能

- **データ読み書き**: セル、行、列の操作
- **数式**: SUM、VLOOKUP等の自動生成
- **グラフ**: 折れ線、棒、円グラフ
- **スタイル**: 色、フォント、罫線
- **条件付き書式**: ルールベースの書式
- **ピボットテーブル**: 集計表作成
- **CSV/JSON変換**: データ変換

## 使用方法

### Python (openpyxl)

```python
from openpyxl import Workbook, load_workbook
from openpyxl.styles import Font, PatternFill
from openpyxl.chart import BarChart, Reference

# 新規作成
wb = Workbook()
ws = wb.active
ws.title = "Sales Data"

# データ入力
ws['A1'] = "Product"
ws['B1'] = "Sales"
ws.append(["iPhone", 1000])
ws.append(["MacBook", 800])

# スタイル設定
ws['A1'].font = Font(bold=True)
ws['A1'].fill = PatternFill(start_color="FFFF00", fill_type="solid")

# グラフ作成
chart = BarChart()
data = Reference(ws, min_col=2, min_row=1, max_row=3)
cats = Reference(ws, min_col=1, min_row=2, max_row=3)
chart.add_data(data, titles_from_data=True)
chart.set_categories(cats)
ws.add_chart(chart, "D1")

wb.save("sales.xlsx")

# 読み込み
wb = load_workbook("sales.xlsx")
ws = wb.active
for row in ws.iter_rows(values_only=True):
    print(row)
```

### JavaScript (ExcelJS)

```javascript
const ExcelJS = require('exceljs');

async function createExcel() {
  const workbook = new ExcelJS.Workbook();
  const worksheet = workbook.addWorksheet('Sales');

  // ヘッダー
  worksheet.columns = [
    { header: 'Product', key: 'product', width: 15 },
    { header: 'Sales', key: 'sales', width: 10 }
  ];

  // データ
  worksheet.addRow({ product: 'iPhone', sales: 1000 });
  worksheet.addRow({ product: 'MacBook', sales: 800 });

  // スタイル
  worksheet.getRow(1).font = { bold: true };
  worksheet.getRow(1).fill = {
    type: 'pattern',
    pattern: 'solid',
    fgColor: { argb: 'FFFFFF00' }
  };

  // 数式
  worksheet.getCell('B4').value = { formula: 'SUM(B2:B3)' };

  await workbook.xlsx.writeFile('sales.xlsx');
}
```

### データ分析 (pandas)

```python
import pandas as pd

# 読み込み
df = pd.read_excel('data.xlsx', sheet_name='Sheet1')

# 分析
summary = df.groupby('Category')['Sales'].sum()

# 書き込み
with pd.ExcelWriter('output.xlsx', engine='openpyxl') as writer:
    df.to_excel(writer, sheet_name='Data', index=False)
    summary.to_excel(writer, sheet_name='Summary')
```

### 高度な機能

```python
from openpyxl.utils.dataframe import dataframe_to_rows
from openpyxl.chart import LineChart, Reference

# データフレームから
import pandas as pd
df = pd.DataFrame({
    'Month': ['Jan', 'Feb', 'Mar'],
    'Sales': [100, 150, 120]
})

wb = Workbook()
ws = wb.active
for r in dataframe_to_rows(df, index=False, header=True):
    ws.append(r)

# 条件付き書式
from openpyxl.formatting.rule import ColorScaleRule
ws.conditional_formatting.add('B2:B4',
    ColorScaleRule(start_type='min', start_color='AA0000',
                   end_type='max', end_color='00AA00'))

# 数式
ws['B5'] = '=AVERAGE(B2:B4)'
ws['B6'] = '=MAX(B2:B4)'

wb.save('advanced.xlsx')
```

## ライブラリ

### Python
- **openpyxl**: .xlsx読み書き
- **xlrd/xlwt**: .xls (旧形式)
- **pandas**: データ分析
- **xlsxwriter**: 高速書き込み

### JavaScript
- **ExcelJS**: 完全機能
- **xlsx**: SheetJS、読み込み特化
- **node-xlsx**: シンプル

### Go
- **excelize**: 高性能

### Java
- **Apache POI**: 標準ライブラリ

## バージョン情報

- スキルバージョン: 1.0.0
- 最終更新: 2025-01-22

Overview

This skill processes Excel files to automate data manipulation, formula generation, chart creation, and styling. It supports reading and writing .xlsx files, converting between CSV/JSON, and generating reports and pivot tables. Versioned utilities and examples are provided for Python, JavaScript, and other ecosystems. Designed for practical spreadsheet automation and repeatable data workflows.

How this skill works

The skill uses common libraries (openpyxl, pandas, xlsxwriter for Python; ExcelJS and SheetJS for JavaScript) to open, modify, and save workbook files. It can programmatically write rows and columns, inject formulas, create charts, apply styles and conditional formatting, and export or import CSV/JSON. For analysis it converts Excel sheets to dataframes, runs groupings and aggregations, and writes summaries or pivot sheets back to workbooks.

When to use it

  • Automate repetitive Excel reporting and formatting tasks
  • Generate formula-driven summaries or calculated columns programmatically
  • Create charts and dashboards from raw data without manual Excel work
  • Convert spreadsheets to CSV or JSON for downstream processing
  • Build reproducible data export/import pipelines between systems

Best practices

  • Work on copies of original workbooks to avoid accidental data loss
  • Use dataframes (pandas) for heavy analytics and then write results to sheets
  • Prefer formulas for dynamic in-spreadsheet calculations and export static results when sharing
  • Apply consistent styles and templates for repeatable report generation
  • Validate cell ranges and types before applying formulas or charts

Example use cases

  • Generate monthly sales reports: read raw sales data, compute totals, add SUM/AVERAGE formulas, and produce bar/line charts
  • Create pivot summaries: aggregate large transaction tables into pivot sheets and export a printable summary
  • Transform exports: convert multi-sheet Excel exports into normalized CSV or JSON for an ETL pipeline
  • Template-driven invoices: populate invoice templates with client data, apply styles, and export PDFs (via print-to-PDF)
  • Data quality checks: scan sheets for missing or outlier values, highlight them with conditional formatting and output an issues sheet

FAQ

Which file formats are supported?

Primary support is .xlsx; older .xls can be handled via xlrd/xlwt tools; CSV and JSON conversion is supported for interchange.

What libraries should I use for heavy analysis?

Use pandas for heavy data manipulation and aggregation, then write results back with openpyxl or xlsxwriter for Excel-specific features.