[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M72A1V9NY4BX0BZAC9M87CEB":3,"skill-same:01M72A1V9NY4BX0BZAC9M87CEB":73},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":53,"commitSha":54,"skillDirectory":5,"forksCount":55,"repositoryHtmlUrl":56,"repositoryHomepageUrl":6,"ownerHtmlUrl":57,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":58,"install":59,"resources":72},"01M72A1V9NY4BX0BZAC9M87CEB","excel-automation",null,">","claude-office-skills\u002Fskills","claude-office-skills","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F258027507?v=4","01M729XQC9FBRQ54AQZS0KY3ZK","AGI Lab","01M729XQCYW6WF9GY762P9RNQJ",575,"MIT","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fexcel-automation\u002FSKILL.md",[],[],"2026-11-10 18:39:20",false,"---\n# ═══════════════════════════════════════════════════════════════════════════════\n# CLAUDE OFFICE SKILL - Enhanced Metadata v2.0\n# ═══════════════════════════════════════════════════════════════════════════════\n\n# Basic Information\nname: excel-automation\ndescription: \">\"\nversion: \"1.0\"\nauthor: claude-office-skills\nlicense: MIT\n\n# Categorization\ncategory: spreadsheet\ntags:\n  - excel\n  - automation\n  - macro\n  - workflow\ndepartment: All\n\n# AI Model Compatibility\nmodels:\n  recommended:\n    - claude-sonnet-4\n    - claude-opus-4\n  compatible:\n    - claude-3-5-sonnet\n    - gpt-4\n    - gpt-4o\n\n# MCP Tools Integration\nmcp:\n  server: office-mcp\n  tools:\n    - read_xlsx\n    - create_xlsx\n    - apply_formula\n    - pivot_table\n\n# Skill Capabilities\ncapabilities:\n  - automation\n  - data_processing\n  - reporting\n\n# Language Support\nlanguages:\n  - en\n  - zh\n---\n\n# Excel Automation Skill\n\n## Overview\n\nThis skill enables advanced Excel automation using **xlwings** - a library that can interact with live Excel instances. Unlike openpyxl (file-only), xlwings can control Excel in real-time, execute VBA, update dashboards, and automate complex workflows.\n\n## How to Use\n\n1. Describe the Excel automation task you need\n2. Specify if you need live Excel interaction or file processing\n3. I'll generate xlwings code and execute it\n\n**Example prompts:**\n- \"Update this live Excel dashboard with new data\"\n- \"Run this VBA macro and get the results\"\n- \"Create an Excel add-in for data validation\"\n- \"Automate monthly report generation with live charts\"\n\n## Domain Knowledge\n\n### xlwings vs openpyxl\n\n| Feature | xlwings | openpyxl |\n|---------|---------|----------|\n| Requires Excel | Yes | No |\n| Live interaction | Yes | No |\n| VBA execution | Yes | No |\n| Speed (large files) | Fast | Slow |\n| Server deployment | Limited | Easy |\n\n### xlwings Fundamentals\n\n```python\nimport xlwings as xw\n\n# Connect to active Excel workbook\nwb = xw.Book.caller()  # From Excel add-in\nwb = xw.books.active   # Active workbook\n\n# Open specific file\nwb = xw.Book('path\u002Fto\u002Ffile.xlsx')\n\n# Create new workbook\nwb = xw.Book()\n\n# Get sheet\nsheet = wb.sheets['Sheet1']\nsheet = wb.sheets[0]\n```\n\n### Working with Ranges\n\n#### Reading and Writing\n```python\n# Single cell\nsheet['A1'].value = 'Hello'\nvalue = sheet['A1'].value\n\n# Range\nsheet['A1:C3'].value = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\ndata = sheet['A1:C3'].value  # Returns list of lists\n\n# Named range\nsheet['MyRange'].value = 'Named data'\n\n# Expand range (detect data boundaries)\nsheet['A1'].expand().value  # All connected data\nsheet['A1'].expand('table').value  # Table format\n```\n\n#### Dynamic Ranges\n```python\n# Current region (like Ctrl+Shift+End)\ndata = sheet['A1'].current_region.value\n\n# Used range\nused = sheet.used_range.value\n\n# Last row with data\nlast_row = sheet['A1'].end('down').row\n\n# Resize range\nrng = sheet['A1'].resize(10, 5)  # 10 rows, 5 columns\n```\n\n### Formatting\n```python\n# Font\nsheet['A1'].font.bold = True\nsheet['A1'].font.size = 14\nsheet['A1'].font.color = (255, 0, 0)  # RGB red\n\n# Fill\nsheet['A1'].color = (255, 255, 0)  # Yellow background\n\n# Number format\nsheet['B1'].number_format = '$#,##0.00'\n\n# Column width\nsheet['A:A'].column_width = 20\n\n# Row height\nsheet['1:1'].row_height = 30\n\n# Autofit\nsheet['A:D'].autofit()\n```\n\n### Excel Features\n\n#### Charts\n```python\n# Add chart\nchart = sheet.charts.add(left=100, top=100, width=400, height=250)\nchart.set_source_data(sheet['A1:B10'])\nchart.chart_type = 'column_clustered'\nchart.name = 'Sales Chart'\n\n# Modify existing chart\nchart = sheet.charts['Sales Chart']\nchart.chart_type = 'line'\n```\n\n#### Tables\n```python\n# Create Excel Table\nrng = sheet['A1'].expand()\ntable = sheet.tables.add(source=rng, name='SalesTable')\n\n# Refresh table\ntable.refresh()\n\n# Access table data\ntable_data = table.data_body_range.value\n```\n\n#### Pictures\n```python\n# Add picture\nsheet.pictures.add('logo.png', left=10, top=10, width=100, height=50)\n\n# Update picture from matplotlib\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots()\nax.plot([1, 2, 3], [1, 4, 9])\nsheet.pictures.add(fig, name='MyPlot', update=True)\n```\n\n### VBA Integration\n```python\n# Run VBA macro\nwb.macro('MacroName')()\n\n# With arguments\nwb.macro('MyMacro')('arg1', 'arg2')\n\n# Get return value\nresult = wb.macro('CalculateTotal')(100, 200)\n\n# Access VBA module\nvb_code = wb.api.VBProject.VBComponents('Module1').CodeModule.Lines(1, 10)\n```\n\n### User Defined Functions (UDFs)\n```python\n# Define a UDF (in Python file)\nimport xlwings as xw\n\n@xw.func\ndef my_sum(x, y):\n    \"\"\"Add two numbers\"\"\"\n    return x + y\n\n@xw.func\n@xw.arg('data', ndim=2)\ndef my_array_func(data):\n    \"\"\"Process array data\"\"\"\n    import numpy as np\n    return np.sum(data)\n\n# These become Excel functions: =my_sum(A1, B1)\n```\n\n### Application Control\n```python\n# Excel application settings\napp = xw.apps.active\napp.screen_updating = False  # Speed up\napp.calculation = 'manual'   # Manual calc\napp.display_alerts = False   # Suppress dialogs\n\n# Perform operations...\n\n# Restore\napp.screen_updating = True\napp.calculation = 'automatic'\napp.display_alerts = True\n```\n\n## Best Practices\n\n1. **Disable Screen Updating**: For batch operations\n2. **Use Arrays**: Read\u002Fwrite entire ranges, not cell-by-cell\n3. **Manual Calculation**: Turn off auto-calc during data loading\n4. **Close Connections**: Properly close workbooks when done\n5. **Error Handling**: Handle Excel not being installed\n\n## Common Patterns\n\n### Performance Optimization\n```python\nimport xlwings as xw\n\ndef batch_update(data, workbook_path):\n    app = xw.App(visible=False)\n    try:\n        app.screen_updating = False\n        app.calculation = 'manual'\n        \n        wb = app.books.open(workbook_path)\n        sheet = wb.sheets['Data']\n        \n        # Write all data at once\n        sheet['A1'].value = data\n        \n        app.calculation = 'automatic'\n        wb.save()\n    finally:\n        wb.close()\n        app.quit()\n```\n\n### Dashboard Update\n```python\ndef update_dashboard(data_dict):\n    wb = xw.books.active\n    \n    # Update data sheet\n    data_sheet = wb.sheets['Data']\n    for name, values in data_dict.items():\n        data_sheet[name].value = values\n    \n    # Refresh all charts\n    dashboard = wb.sheets['Dashboard']\n    for chart in dashboard.charts:\n        chart.refresh()\n    \n    # Update timestamp\n    from datetime import datetime\n    dashboard['A1'].value = f'Last Updated: {datetime.now()}'\n```\n\n### Report Generator\n```python\ndef generate_monthly_report(month, data):\n    template = xw.Book('template.xlsx')\n    \n    # Fill data\n    sheet = template.sheets['Report']\n    sheet['B2'].value = month\n    sheet['A5'].value = data\n    \n    # Run calculations\n    template.app.calculate()\n    \n    # Export to PDF\n    sheet.api.ExportAsFixedFormat(0, f'report_{month}.pdf')\n    \n    template.save(f'report_{month}.xlsx')\n```\n\n## Examples\n\n### Example 1: Live Dashboard Update\n```python\nimport xlwings as xw\nimport pandas as pd\nfrom datetime import datetime\n\n# Connect to running Excel\nwb = xw.books.active\ndashboard = wb.sheets['Dashboard']\ndata_sheet = wb.sheets['Data']\n\n# Fetch new data (simulated)\nnew_data = pd.DataFrame({\n    'Date': pd.date_range('2024-01-01', periods=30),\n    'Sales': [1000 + i*50 for i in range(30)],\n    'Costs': [600 + i*30 for i in range(30)]\n})\n\n# Update data sheet\ndata_sheet['A1'].value = new_data\n\n# Calculate profit\ndata_sheet['D1'].value = 'Profit'\ndata_sheet['D2'].value = '=B2-C2'\ndata_sheet['D2'].expand('down').value = data_sheet['D2'].formula\n\n# Update KPIs on dashboard\ndashboard['B2'].value = new_data['Sales'].sum()\ndashboard['B3'].value = new_data['Costs'].sum()\ndashboard['B4'].value = new_data['Sales'].sum() - new_data['Costs'].sum()\ndashboard['A1'].value = f'Updated: {datetime.now().strftime(\"%Y-%m-%d %H:%M\")}'\n\n# Refresh charts\nfor chart in dashboard.charts:\n    chart.api.Refresh()\n\nprint(\"Dashboard updated!\")\n```\n\n### Example 2: Batch Processing Multiple Files\n```python\nimport xlwings as xw\nfrom pathlib import Path\n\ndef process_sales_files(folder_path, output_path):\n    \"\"\"Consolidate multiple Excel files into one summary.\"\"\"\n    \n    app = xw.App(visible=False)\n    app.screen_updating = False\n    \n    try:\n        # Create summary workbook\n        summary_wb = xw.Book()\n        summary_sheet = summary_wb.sheets[0]\n        summary_sheet.name = 'Consolidated'\n        \n        headers = ['File', 'Total Sales', 'Total Units', 'Avg Price']\n        summary_sheet['A1'].value = headers\n        \n        row = 2\n        for file in Path(folder_path).glob('*.xlsx'):\n            wb = app.books.open(str(file))\n            data_sheet = wb.sheets['Sales']\n            \n            # Extract summary\n            total_sales = data_sheet['B:B'].api.SpecialCells(11).Value  # xlCellTypeConstants\n            total_units = data_sheet['C:C'].api.SpecialCells(11).Value\n            \n            # Calculate and write\n            summary_sheet[f'A{row}'].value = file.name\n            summary_sheet[f'B{row}'].value = sum(total_sales) if isinstance(total_sales, (list, tuple)) else total_sales\n            summary_sheet[f'C{row}'].value = sum(total_units) if isinstance(total_units, (list, tuple)) else total_units\n            summary_sheet[f'D{row}'].value = f'=B{row}\u002FC{row}'\n            \n            wb.close()\n            row += 1\n        \n        # Format summary\n        summary_sheet['A1:D1'].font.bold = True\n        summary_sheet['B:D'].number_format = '$#,##0.00'\n        summary_sheet['A:D'].autofit()\n        \n        summary_wb.save(output_path)\n        \n    finally:\n        app.quit()\n    \n    print(f\"Consolidated {row-2} files to {output_path}\")\n\n# Usage\nprocess_sales_files('\u002Fpath\u002Fto\u002Fsales\u002F', 'consolidated_sales.xlsx')\n```\n\n### Example 3: Excel Add-in with UDFs\n```python\n# myudfs.py - Place in xlwings project\n\nimport xlwings as xw\nimport numpy as np\n\n@xw.func\n@xw.arg('data', pd.DataFrame, index=False, header=False)\n@xw.ret(expand='table')\ndef GROWTH_RATE(data):\n    \"\"\"Calculate period-over-period growth rate\"\"\"\n    values = data.iloc[:, 0].values\n    growth = np.diff(values) \u002F values[:-1] * 100\n    return [['Growth %']] + [[g] for g in growth]\n\n@xw.func\n@xw.arg('range1', np.array, ndim=2)\n@xw.arg('range2', np.array, ndim=2)\ndef CORRELATION(range1, range2):\n    \"\"\"Calculate correlation between two ranges\"\"\"\n    return np.corrcoef(range1.flatten(), range2.flatten())[0, 1]\n\n@xw.func\ndef SENTIMENT(text):\n    \"\"\"Basic sentiment analysis (placeholder)\"\"\"\n    positive = ['good', 'great', 'excellent', 'amazing']\n    negative = ['bad', 'poor', 'terrible', 'awful']\n    \n    text_lower = text.lower()\n    pos_count = sum(word in text_lower for word in positive)\n    neg_count = sum(word in text_lower for word in negative)\n    \n    if pos_count > neg_count:\n        return 'Positive'\n    elif neg_count > pos_count:\n        return 'Negative'\n    return 'Neutral'\n```\n\n## Limitations\n\n- Requires Excel to be installed\n- Limited support on macOS for some features\n- Not suitable for server-side processing\n- VBA features require trust settings\n- Performance varies with Excel version\n\n## Installation\n\n```bash\npip install xlwings\n\n# For add-in functionality\nxlwings addin install\n```\n\n## Resources\n\n- [xlwings Documentation](https:\u002F\u002Fdocs.xlwings.org\u002F)\n- [GitHub Repository](https:\u002F\u002Fgithub.com\u002Fxlwings\u002Fxlwings)\n- [UDF Tutorial](https:\u002F\u002Fdocs.xlwings.org\u002Fen\u002Fstable\u002Fudfs.html)\n- [Excel VBA Reference](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Foffice\u002Fvba\u002Fapi\u002Foverview\u002Fexcel)\n","# Excel Automation Skill\n\n## Overview\n\nThis skill enables advanced Excel automation using **xlwings** - a library that can interact with live Excel instances. Unlike openpyxl (file-only), xlwings can control Excel in real-time, execute VBA, update dashboards, and automate complex workflows.\n\n## How to Use\n\n1. Describe the Excel automation task you need\n2. Specify if you need live Excel interaction or file processing\n3. I'll generate xlwings code and execute it\n\n**Example prompts:**\n- \"Update this live Excel dashboard with new data\"\n- \"Run this VBA macro and get the results\"\n- \"Create an Excel add-in for data validation\"\n- \"Automate monthly report generation with live charts\"\n\n## Domain Knowledge\n\n### xlwings vs openpyxl\n\n| Feature | xlwings | openpyxl |\n|---------|---------|----------|\n| Requires Excel | Yes | No |\n| Live interaction | Yes | No |\n| VBA execution | Yes | No |\n| Speed (large files) | Fast | Slow |\n| Server deployment | Limited | Easy |\n\n### xlwings Fundamentals\n\n```python\nimport xlwings as xw\n\n# Connect to active Excel workbook\nwb = xw.Book.caller()  # From Excel add-in\nwb = xw.books.active   # Active workbook\n\n# Open specific file\nwb = xw.Book('path\u002Fto\u002Ffile.xlsx')\n\n# Create new workbook\nwb = xw.Book()\n\n# Get sheet\nsheet = wb.sheets['Sheet1']\nsheet = wb.sheets[0]\n```\n\n### Working with Ranges\n\n#### Reading and Writing\n```python\n# Single cell\nsheet['A1'].value = 'Hello'\nvalue = sheet['A1'].value\n\n# Range\nsheet['A1:C3'].value = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]\ndata = sheet['A1:C3'].value  # Returns list of lists\n\n# Named range\nsheet['MyRange'].value = 'Named data'\n\n# Expand range (detect data boundaries)\nsheet['A1'].expand().value  # All connected data\nsheet['A1'].expand('table').value  # Table format\n```\n\n#### Dynamic Ranges\n```python\n# Current region (like Ctrl+Shift+End)\ndata = sheet['A1'].current_region.value\n\n# Used range\nused = sheet.used_range.value\n\n# Last row with data\nlast_row = sheet['A1'].end('down').row\n\n# Resize range\nrng = sheet['A1'].resize(10, 5)  # 10 rows, 5 columns\n```\n\n### Formatting\n```python\n# Font\nsheet['A1'].font.bold = True\nsheet['A1'].font.size = 14\nsheet['A1'].font.color = (255, 0, 0)  # RGB red\n\n# Fill\nsheet['A1'].color = (255, 255, 0)  # Yellow background\n\n# Number format\nsheet['B1'].number_format = '$#,##0.00'\n\n# Column width\nsheet['A:A'].column_width = 20\n\n# Row height\nsheet['1:1'].row_height = 30\n\n# Autofit\nsheet['A:D'].autofit()\n```\n\n### Excel Features\n\n#### Charts\n```python\n# Add chart\nchart = sheet.charts.add(left=100, top=100, width=400, height=250)\nchart.set_source_data(sheet['A1:B10'])\nchart.chart_type = 'column_clustered'\nchart.name = 'Sales Chart'\n\n# Modify existing chart\nchart = sheet.charts['Sales Chart']\nchart.chart_type = 'line'\n```\n\n#### Tables\n```python\n# Create Excel Table\nrng = sheet['A1'].expand()\ntable = sheet.tables.add(source=rng, name='SalesTable')\n\n# Refresh table\ntable.refresh()\n\n# Access table data\ntable_data = table.data_body_range.value\n```\n\n#### Pictures\n```python\n# Add picture\nsheet.pictures.add('logo.png', left=10, top=10, width=100, height=50)\n\n# Update picture from matplotlib\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots()\nax.plot([1, 2, 3], [1, 4, 9])\nsheet.pictures.add(fig, name='MyPlot', update=True)\n```\n\n### VBA Integration\n```python\n# Run VBA macro\nwb.macro('MacroName')()\n\n# With arguments\nwb.macro('MyMacro')('arg1', 'arg2')\n\n# Get return value\nresult = wb.macro('CalculateTotal')(100, 200)\n\n# Access VBA module\nvb_code = wb.api.VBProject.VBComponents('Module1').CodeModule.Lines(1, 10)\n```\n\n### User Defined Functions (UDFs)\n```python\n# Define a UDF (in Python file)\nimport xlwings as xw\n\n@xw.func\ndef my_sum(x, y):\n    \"\"\"Add two numbers\"\"\"\n    return x + y\n\n@xw.func\n@xw.arg('data', ndim=2)\ndef my_array_func(data):\n    \"\"\"Process array data\"\"\"\n    import numpy as np\n    return np.sum(data)\n\n# These become Excel functions: =my_sum(A1, B1)\n```\n\n### Application Control\n```python\n# Excel application settings\napp = xw.apps.active\napp.screen_updating = False  # Speed up\napp.calculation = 'manual'   # Manual calc\napp.display_alerts = False   # Suppress dialogs\n\n# Perform operations...\n\n# Restore\napp.screen_updating = True\napp.calculation = 'automatic'\napp.display_alerts = True\n```\n\n## Best Practices\n\n1. **Disable Screen Updating**: For batch operations\n2. **Use Arrays**: Read\u002Fwrite entire ranges, not cell-by-cell\n3. **Manual Calculation**: Turn off auto-calc during data loading\n4. **Close Connections**: Properly close workbooks when done\n5. **Error Handling**: Handle Excel not being installed\n\n## Common Patterns\n\n### Performance Optimization\n```python\nimport xlwings as xw\n\ndef batch_update(data, workbook_path):\n    app = xw.App(visible=False)\n    try:\n        app.screen_updating = False\n        app.calculation = 'manual'\n        \n        wb = app.books.open(workbook_path)\n        sheet = wb.sheets['Data']\n        \n        # Write all data at once\n        sheet['A1'].value = data\n        \n        app.calculation = 'automatic'\n        wb.save()\n    finally:\n        wb.close()\n        app.quit()\n```\n\n### Dashboard Update\n```python\ndef update_dashboard(data_dict):\n    wb = xw.books.active\n    \n    # Update data sheet\n    data_sheet = wb.sheets['Data']\n    for name, values in data_dict.items():\n        data_sheet[name].value = values\n    \n    # Refresh all charts\n    dashboard = wb.sheets['Dashboard']\n    for chart in dashboard.charts:\n        chart.refresh()\n    \n    # Update timestamp\n    from datetime import datetime\n    dashboard['A1'].value = f'Last Updated: {datetime.now()}'\n```\n\n### Report Generator\n```python\ndef generate_monthly_report(month, data):\n    template = xw.Book('template.xlsx')\n    \n    # Fill data\n    sheet = template.sheets['Report']\n    sheet['B2'].value = month\n    sheet['A5'].value = data\n    \n    # Run calculations\n    template.app.calculate()\n    \n    # Export to PDF\n    sheet.api.ExportAsFixedFormat(0, f'report_{month}.pdf')\n    \n    template.save(f'report_{month}.xlsx')\n```\n\n## Examples\n\n### Example 1: Live Dashboard Update\n```python\nimport xlwings as xw\nimport pandas as pd\nfrom datetime import datetime\n\n# Connect to running Excel\nwb = xw.books.active\ndashboard = wb.sheets['Dashboard']\ndata_sheet = wb.sheets['Data']\n\n# Fetch new data (simulated)\nnew_data = pd.DataFrame({\n    'Date': pd.date_range('2024-01-01', periods=30),\n    'Sales': [1000 + i*50 for i in range(30)],\n    'Costs': [600 + i*30 for i in range(30)]\n})\n\n# Update data sheet\ndata_sheet['A1'].value = new_data\n\n# Calculate profit\ndata_sheet['D1'].value = 'Profit'\ndata_sheet['D2'].value = '=B2-C2'\ndata_sheet['D2'].expand('down').value = data_sheet['D2'].formula\n\n# Update KPIs on dashboard\ndashboard['B2'].value = new_data['Sales'].sum()\ndashboard['B3'].value = new_data['Costs'].sum()\ndashboard['B4'].value = new_data['Sales'].sum() - new_data['Costs'].sum()\ndashboard['A1'].value = f'Updated: {datetime.now().strftime(\"%Y-%m-%d %H:%M\")}'\n\n# Refresh charts\nfor chart in dashboard.charts:\n    chart.api.Refresh()\n\nprint(\"Dashboard updated!\")\n```\n\n### Example 2: Batch Processing Multiple Files\n```python\nimport xlwings as xw\nfrom pathlib import Path\n\ndef process_sales_files(folder_path, output_path):\n    \"\"\"Consolidate multiple Excel files into one summary.\"\"\"\n    \n    app = xw.App(visible=False)\n    app.screen_updating = False\n    \n    try:\n        # Create summary workbook\n        summary_wb = xw.Book()\n        summary_sheet = summary_wb.sheets[0]\n        summary_sheet.name = 'Consolidated'\n        \n        headers = ['File', 'Total Sales', 'Total Units', 'Avg Price']\n        summary_sheet['A1'].value = headers\n        \n        row = 2\n        for file in Path(folder_path).glob('*.xlsx'):\n            wb = app.books.open(str(file))\n            data_sheet = wb.sheets['Sales']\n            \n            # Extract summary\n            total_sales = data_sheet['B:B'].api.SpecialCells(11).Value  # xlCellTypeConstants\n            total_units = data_sheet['C:C'].api.SpecialCells(11).Value\n            \n            # Calculate and write\n            summary_sheet[f'A{row}'].value = file.name\n            summary_sheet[f'B{row}'].value = sum(total_sales) if isinstance(total_sales, (list, tuple)) else total_sales\n            summary_sheet[f'C{row}'].value = sum(total_units) if isinstance(total_units, (list, tuple)) else total_units\n            summary_sheet[f'D{row}'].value = f'=B{row}\u002FC{row}'\n            \n            wb.close()\n            row += 1\n        \n        # Format summary\n        summary_sheet['A1:D1'].font.bold = True\n        summary_sheet['B:D'].number_format = '$#,##0.00'\n        summary_sheet['A:D'].autofit()\n        \n        summary_wb.save(output_path)\n        \n    finally:\n        app.quit()\n    \n    print(f\"Consolidated {row-2} files to {output_path}\")\n\n# Usage\nprocess_sales_files('\u002Fpath\u002Fto\u002Fsales\u002F', 'consolidated_sales.xlsx')\n```\n\n### Example 3: Excel Add-in with UDFs\n```python\n# myudfs.py - Place in xlwings project\n\nimport xlwings as xw\nimport numpy as np\n\n@xw.func\n@xw.arg('data', pd.DataFrame, index=False, header=False)\n@xw.ret(expand='table')\ndef GROWTH_RATE(data):\n    \"\"\"Calculate period-over-period growth rate\"\"\"\n    values = data.iloc[:, 0].values\n    growth = np.diff(values) \u002F values[:-1] * 100\n    return [['Growth %']] + [[g] for g in growth]\n\n@xw.func\n@xw.arg('range1', np.array, ndim=2)\n@xw.arg('range2', np.array, ndim=2)\ndef CORRELATION(range1, range2):\n    \"\"\"Calculate correlation between two ranges\"\"\"\n    return np.corrcoef(range1.flatten(), range2.flatten())[0, 1]\n\n@xw.func\ndef SENTIMENT(text):\n    \"\"\"Basic sentiment analysis (placeholder)\"\"\"\n    positive = ['good', 'great', 'excellent', 'amazing']\n    negative = ['bad', 'poor', 'terrible', 'awful']\n    \n    text_lower = text.lower()\n    pos_count = sum(word in text_lower for word in positive)\n    neg_count = sum(word in text_lower for word in negative)\n    \n    if pos_count > neg_count:\n        return 'Positive'\n    elif neg_count > pos_count:\n        return 'Negative'\n    return 'Neutral'\n```\n\n## Limitations\n\n- Requires Excel to be installed\n- Limited support on macOS for some features\n- Not suitable for server-side processing\n- VBA features require trust settings\n- Performance varies with Excel version\n\n## Installation\n\n```bash\npip install xlwings\n\n# For add-in functionality\nxlwings addin install\n```\n\n## Resources\n\n- [xlwings Documentation](https:\u002F\u002Fdocs.xlwings.org\u002F)\n- [GitHub Repository](https:\u002F\u002Fgithub.com\u002Fxlwings\u002Fxlwings)\n- [UDF Tutorial](https:\u002F\u002Fdocs.xlwings.org\u002Fen\u002Fstable\u002Fudfs.html)\n- [Excel VBA Reference](https:\u002F\u002Fdocs.microsoft.com\u002Fen-us\u002Foffice\u002Fvba\u002Fapi\u002Foverview\u002Fexcel)\n",{"mcp":24,"name":5,"tags":31,"author":9,"models":36,"license":15,"version":44,"category":45,"languages":46,"department":49,"description":7,"capabilities":50},{"tools":25,"server":30},[26,27,28,29],"read_xlsx","create_xlsx","apply_formula","pivot_table","office-mcp",[32,33,34,35],"excel","automation","macro","workflow",{"compatible":37,"recommended":41},[38,39,40],"claude-3-5-sonnet","gpt-4","gpt-4o",[42,43],"claude-sonnet-4","claude-opus-4","1.0","spreadsheet",[47,48],"en","zh","All",[33,51,52],"data_processing","reporting","main","9c4c7d5cd2813a8936bf2c9fdb174ea883b85a11",105,"https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills","2026-01-31 22:03:56",{"source":8,"skillName":5,"commands":60,"prompt":70,"zipAvailable":71},[61,64,67],{"tool":62,"command":63},"npx","npx skills add claude-office-skills\u002Fskills --skill excel-automation",{"tool":65,"command":66},"bunx","bunx skills add claude-office-skills\u002Fskills --skill excel-automation",{"tool":68,"command":69},"pnpm","pnpm dlx skills add claude-office-skills\u002Fskills --skill excel-automation","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fexcel-automation\u002FSKILL.md",true,[],[74,81,87,94,101,108],{"skillNo":75,"name":76,"nameZh":6,"description":77,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":78,"categories":79,"keywords":80,"publishedAt":19},"01M72A0X7X4TWS4ZWTEK8TJEC8","devops-automation","DevOps and IT Ops automation - CI\u002FCD, monitoring, incident management, and infrastructure workflows","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdevops-automation\u002FSKILL.md",[],[],{"skillNo":82,"name":83,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":84,"categories":85,"keywords":86,"publishedAt":19},"01M72A0VPXF4Q5F48TPDG6S10Q","dev-slides","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdev-slides\u002FSKILL.md",[],[],{"skillNo":88,"name":89,"nameZh":6,"description":90,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":91,"categories":92,"keywords":93,"publishedAt":19},"01M72A0Q1T0KN60CR3PAD93J6T","deep-research","Conduct comprehensive research on any topic. Synthesize information from multiple angles, provide structured analysis, and generate detailed research reports.","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdeep-research\u002FSKILL.md",[],[],{"skillNo":95,"name":96,"nameZh":6,"description":97,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":98,"categories":99,"keywords":100,"publishedAt":19},"01M72A0KWAYEWQJMDRGC0WTT7V","dcf-valuation","Build Discounted Cash Flow (DCF) valuation models. Calculate intrinsic value with customizable assumptions. Generate professional valuation reports.","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdcf-valuation\u002FSKILL.md",[],[],{"skillNo":102,"name":103,"nameZh":6,"description":104,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":105,"categories":106,"keywords":107,"publishedAt":19},"01M72A0GVWRZ3HZNXMW3RB5CF9","Database Sync","Automate database synchronization, replication, migration, and cross-platform data integration","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdatabase-sync\u002FSKILL.md",[],[],{"skillNo":109,"name":110,"nameZh":6,"description":111,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M72A0E16K862EDP0QYEAC9HJ","data-pipeline","Data pipeline and ETL automation - extract, transform, load workflows for data integration and analytics","https:\u002F\u002Fgithub.com\u002Fclaude-office-skills\u002Fskills\u002Fblob\u002Fmain\u002Fdata-pipeline\u002FSKILL.md",[],[]]