Tutorial: Build an Excel Data Tool
In this tutorial, youâll build a tool that reads your own Excel or Google Sheets data and performs analysis, visualization, and report generation.
Final Result
ăSales Data Analysis Reportă
Period: January - March 2024
ăMonthly Salesă
January: $12,345 (+5.2% MoM)
February: $13,456 (+9.0% MoM)
March: $14,567 (+8.3% MoM)
ăProduct Rankingsă
1st: Product A - $5,678
2nd: Product B - $4,567
3rd: Product C - $3,456
ăChartsă
[Sales trend graph displayed]Time Required
1-2 hours
Prerequisites
- Environment setup is complete
- Excel file or Google Sheets access for analysis
If You Donât Have Sample Data
The tutorial will create sample data, so you can proceed without having data on hand.
Step 1: Create Project
Open Folder in VS Code
- Launch VS Code
- From the menu, select âFileâ â âOpen Folderâ
- Create and open a new folder called
~/projects/excel-analyzer
Open Claude Code
Click the Claude icon in the left sidebar to open the chat panel.
Step 2: Create Sample Data
First, letâs create sample data for practice.
Tell Claude
Create a sample Excel file with sales data.
Filename: sales_data.xlsx
Columns:
- Date
- Product Name
- Category
- Quantity
- Unit Price
- Sales Amount
- Sales Rep
- Region
Data:
- 3 months from January to March 2024
- About 100 rows of realistic data
- About 5 different products
- About 3 sales reps
- Regions: East, West, Central
Use openpyxl to create it.Verify
Check if sales_data.xlsx was created. Display the first 10 rows.Step 3: Read and Display Data
Create a basic script to read the Excel file.
Tell Claude
Create a Python script to read and display sales_data.xlsx.
Filename: analyzer.py
Features:
- Read Excel file with pandas
- Display basic info (row count, column list)
- Show first 10 rows
Usage: python analyzer.py sales_data.xlsxStep 4: Add Basic Analysis Features
Add data aggregation and analysis features.
Tell Claude
Add analysis features to analyzer.py.
Features to add:
1. Monthly sales totals
2. Product sales ranking (top 5)
3. Sales by sales rep
4. Sales by region
Format results for easy reading.Step 5: Visualize with Charts
Visualize the analysis results with charts.
Tell Claude
Add chart display features to analyzer.py.
Charts to create:
1. Bar chart of monthly sales
2. Pie chart of sales by product
3. Line chart of daily sales
Use matplotlib.
Enable Japanese text display.
Save charts as PNG images.Step 6: Auto-Generate Reports
Output analysis results as a report file.
Tell Claude
Add a feature to output analysis results as a Markdown report.
Report contents:
- Title (data filename and date)
- Summary (total sales, count, period)
- Monthly sales
- Product rankings
- Sales rep analysis
- Regional analysis
- Embedded chart images
Filename: report_YYYYMMDD.mdUsing Google Sheets
Steps if you want to use Google Sheets instead of Excel.
Tell Claude
Modify to read data from Google Sheets.
Features:
- Use Google Sheets API
- Specify spreadsheet ID as argument
- Allow sheet name specification (default to first sheet)
Use service account for authentication.Google Sheets API Setup
- Go to Google Cloud ConsoleÂ
- Enable âGoogle Sheets APIâ in âAPIs & Servicesâ â âLibraryâ
- Create a service account in âCredentialsâ
- Download the service account key (JSON)
- Share the target sheet with the service accountâs email address in Google Sheets
Try with Your Own Data
Once the tutorial works, try it with your own business data.
Prepare Your Data
- Sales data
- Customer lists
- Inventory data
- Attendance data
- Expense data
Copy the Excel file you want to analyze to the excel-analyzer folder.
Customize the Analysis
@your-file.xlsx Analyze this file.
Check the column structure and suggest what can be analyzed.Claude will automatically analyze the data structure and suggest appropriate analyses.
Advanced Challenges (If Time Permits)
Add a Web UI
Add a web interface to this tool.
- Upload a file
- Click analyze button
- Display results and charts
Use Flask or Streamlit.Automated Weekly Reports
Add a feature to automatically generate last week's sales report
every Monday and post it to Slack.Compare Multiple Files
Add a feature to compare two Excel files and show the differences.
Example: Compare last month's and this month's salesPDF Output
Make it possible to output reports in PDF format as wellTroubleshooting
âopenpyxl is not installedâ
Install openpyxlJapanese Characters Are Garbled
Check the Excel file's character encoding.
Specify UTF-8 when reading.Japanese Text Shows as Boxes in Charts
Set up Japanese fonts for matplotlib.
Use Hiragino Kaku Gothic for Mac, Meiryo for Windows.Google Sheets Authentication Error
Check the path to the service account credentials file.
Verify the sheet is shared with the service account.Checklist
- Opened Claude Codeâs chat panel in VS Code
- Created sample data (sales_data.xlsx)
- Read data with analyzer.py
- Performed basic analysis (monthly, by product, etc.)
- Generated charts
- Output a report
- (Optional) Analyzed with your own data
Next Steps
- Morning Notification Tool - Try API integration
- Sample Templates - Explore other ideas
Use the data processing knowledge from this tutorial to build business efficiency tools!