# Excel MCP Usage Examples

**Last Updated:** 2026-03-08

## Overview

This document provides practical examples of using Excel MCP for template inspection, debugging, and validation. These examples demonstrate common workflows for corruption diagnosis, formula verification, and structure validation.

## Example Prompts

### 1. Basic File Inspection

**Prompt:**
```
Use Excel MCP to inspect v2/systems/excel-template-generator/output/generated-templates/dienstplan-excel-vorlage.xlsx
```

**Use Case:** General inspection of template structure, sheets, and basic information

**Expected Output:** File structure, sheet names, basic metadata

### 2. Formula Verification

**Prompt:**
```
Use Excel MCP to read formulas from v2/systems/excel-template-generator/output/generated-templates/dienstplan-excel-vorlage.xlsx and verify they use English function names (SUM, IF, VLOOKUP, not SUMME, WENN, SVERWEIS)
```

**Use Case:** Verify formulas match template definition and use correct function names

**Expected Output:** List of formulas with cell addresses, verification of English function names

### 3. Data Validation Rules Check

**Prompt:**
```
Use Excel MCP to inspect v2/systems/excel-template-generator/output/generated-templates/schichtplan-excel-vorlage.xlsx and verify data validation rules are correctly applied to input cells
```

**Use Case:** Verify data validation rules match template definition

**Expected Output:** Data validation rules with cell ranges and validation types

### 4. Conditional Formatting Verification

**Prompt:**
```
Use Excel MCP to check conditional formatting in v2/systems/excel-template-generator/output/generated-templates/compliance-checkliste-vorlage.xlsx
```

**Use Case:** Verify conditional formatting ranges and rules match template definition

**Expected Output:** Conditional formatting rules with cell ranges and formatting conditions

### 5. Structure Comparison

**Prompt:**
```
Use Excel MCP to compare the structure of v2/systems/excel-template-generator/output/generated-templates/dienstplan-excel-vorlage.xlsx against the template definition in v2/systems/excel-template-generator/data/template-definitions/examples/dienstplan-basic.json
```

**Use Case:** Verify generated template matches template definition

**Expected Output:** Comparison of sheets, named ranges, data validation, conditional formatting

### 6. Corruption Diagnosis

**Prompt:**
```
After running validate-generated-xlsx.py found issues with compliance-checkliste-vorlage.xlsx, use Excel MCP to inspect the file structure and identify the cause of corruption
```

**Use Case:** Diagnose corruption issues found by validation scripts

**Expected Output:** Detailed inspection of file structure, formulas, data validation, conditional formatting

### 7. Cell Value Inspection

**Prompt:**
```
Use Excel MCP to read cell values from v2/systems/excel-template-generator/output/generated-templates/stundenzettel-excel-vorlage.xlsx, sheet "Daten", range A1:H10
```

**Use Case:** Verify example data rows are present and correctly formatted

**Expected Output:** Cell values from specified range

### 8. Sheet Structure Verification

**Prompt:**
```
Use Excel MCP to verify sheet names in v2/systems/excel-template-generator/output/generated-templates/gefaehrdungsbeurteilung-vorlage.xlsx match the template definition
```

**Use Case:** Verify all expected sheets are present with correct names

**Expected Output:** List of sheet names, comparison with template definition

## Workflow Examples

### Workflow 1: Corruption Diagnosis

**Scenario:** User reports Excel repair prompt for a template

**Steps:**

1. **Run automated validation:**
   ```bash
   python3 v2/scripts/dev-helpers/validate-generated-xlsx.py
   ```

2. **If issues found, inspect structure:**
   ```bash
   python3 v2/scripts/dev-helpers/inspect-xlsx-structure.py v2/systems/excel-template-generator/output/generated-templates/template.xlsx
   ```

3. **Use Excel MCP for detailed inspection:**
   ```
   Use Excel MCP to inspect v2/systems/excel-template-generator/output/generated-templates/template.xlsx and identify corruption causes
   ```

4. **Read formulas to verify correctness:**
   ```
   Use Excel MCP to read formulas from v2/systems/excel-template-generator/output/generated-templates/template.xlsx
   ```

5. **Check data validation rules:**
   ```
   Use Excel MCP to verify data validation rules in v2/systems/excel-template-generator/output/generated-templates/template.xlsx
   ```

6. **Fix issues in template definition and regenerate**

### Workflow 2: Formula Verification After Template Update

**Scenario:** Updated template definition with new formulas, need to verify they're correctly applied

**Steps:**

1. **Regenerate template:**
   ```bash
   php v2/systems/excel-template-generator/scripts/template-cli.php generate template.json output.xlsx
   ```

2. **Use Excel MCP to read formulas:**
   ```
   Use Excel MCP to read formulas from output.xlsx and compare against template definition
   ```

3. **Verify formula syntax and cell references:**
   ```
   Use Excel MCP to verify formula syntax in output.xlsx matches template definition
   ```

4. **Check for English function names:**
   ```
   Use Excel MCP to verify all formulas use English function names (SUM, IF, VLOOKUP) not German (SUMME, WENN, SVERWEIS)
   ```

### Workflow 3: Quality Check Before Deploy

**Scenario:** Final quality check before deploying updated templates

**Steps:**

1. **Run automated validation:**
   ```bash
   php v2/scripts/templates/validate-template-excel-quality.php --template=slug
   ```

2. **Use Excel MCP for detailed structure check:**
   ```
   Use Excel MCP to inspect v2/systems/excel-template-generator/output/generated-templates/template.xlsx and verify:
   - Sheet names match template definition
   - Data validation rules are correctly applied
   - Conditional formatting ranges are correct
   - Example data rows are present
   ```

3. **Verify formulas:**
   ```
   Use Excel MCP to read formulas from v2/systems/excel-template-generator/output/generated-templates/template.xlsx
   ```

4. **Manual verification:** Open in Excel/LibreOffice to check for repair prompts

## Common Use Cases

### Use Case 1: Debugging Formula Issues

**Problem:** Formulas not calculating correctly

**Excel MCP Usage:**
```
Use Excel MCP to read formulas from template.xlsx and identify:
- Formulas with syntax errors
- Invalid cell references
- Missing named ranges
- Incorrect function names
```

### Use Case 2: Verifying Data Validation

**Problem:** Data validation not working as expected

**Excel MCP Usage:**
```
Use Excel MCP to inspect data validation rules in template.xlsx and verify:
- Validation rules are applied to correct cells
- Validation types match template definition
- Formula1/Formula2 values are correct
```

### Use Case 3: Checking Conditional Formatting

**Problem:** Conditional formatting not displaying correctly

**Excel MCP Usage:**
```
Use Excel MCP to check conditional formatting in template.xlsx and verify:
- Conditional formatting ranges are correct
- Formatting conditions match template definition
- Formatting styles are applied correctly
```

### Use Case 4: Template Structure Verification

**Problem:** Template structure doesn't match definition

**Excel MCP Usage:**
```
Use Excel MCP to compare template.xlsx structure against template definition:
- Sheet names and count
- Named ranges
- Data validation rules
- Conditional formatting ranges
- Cell values and formulas
```

## Tips and Best Practices

### 1. Use Specific File Paths

Always use full relative paths from workspace root:
```
✅ v2/systems/excel-template-generator/output/generated-templates/dienstplan-excel-vorlage.xlsx
❌ dienstplan-excel-vorlage.xlsx
```

### 2. Combine with Validation Scripts

Use Excel MCP after running validation scripts, not instead of:
```
1. Run validate-generated-xlsx.py
2. If issues found → Use Excel MCP for detailed inspection
3. Fix issues → Regenerate → Repeat
```

### 3. Document Findings

When using Excel MCP to diagnose issues:
- Document findings in issue reports
- Update template definitions based on findings
- Improve validation scripts based on discovered patterns

### 4. Verify Results

Cross-reference Excel MCP findings with:
- Python/PHP validation scripts
- Template definition files
- Manual Excel inspection

## References

- [EXCEL_MCP_INTEGRATION.md](EXCEL_MCP_INTEGRATION.md) – Integration guide
- [EXCEL_TEMPLATE_BEST_PRACTICES.md](EXCEL_TEMPLATE_BEST_PRACTICES.md) – Best practices
- [MCP_INTEGRATION.md](../../development/MCP_INTEGRATION.md) – MCP integration guide
- [Excel MCP Server GitHub](https://github.com/haris-musa/excel-mcp-server) – Excel MCP server documentation
