Skip to main content

XPyCode Master - Python scripting for Excel with VBA-like interface

Project description

XPyCode

Python 3.9+ License: MIT + Commons Clause Platform: Windows Platform: macOS Platform: Linux (experimental)

XPyCode is an Excel-Python integration platform that enables you to write, execute, and manage Python code directly within Microsoft Excel workbooks. It provides a seamless bridge between Excel and Python, featuring a full-featured IDE, custom function publishing, package management, and real-time debugging.

Project status

โš ๏ธ This version is at early stage. It is a Beta version.

๐Ÿšจ Don't use for production or in sensitive environement ๐Ÿšจ

Help Keep the Project Alive

โญ Add a star in GitHub to promote the project

๐Ÿ’ต Donate (for instance 3โ‚ฌ per month)

๐Ÿ’ฌ Join the XPyCode Slack community to ask questions, share feedback, and connect with other users: ๐Ÿ‘‰ Invite link ๐Ÿ‘‰ Workspace

Features

  • ๐Ÿ Python Execution in Excel - Run Python code with full access to Excel objects
  • ๐Ÿ“ Integrated IDE - Monaco-based code editor with IntelliSense, syntax highlighting, and debugging
  • ๐Ÿ“ฆ Package Manager - Install and manage Python packages per workbook with dependency resolution
  • ๐Ÿ”ง Custom Functions (UDFs) - Publish Python functions as Excel formulas
  • ๐ŸŽฏ Event Handling - React to Excel events (worksheet changes, selections, etc.) with Python
  • ๐Ÿ” Object Management - Save and re-use objects in python kernel
  • ๐Ÿ› Debugger - Set breakpoints, step through code, and inspect variables
  • ๐ŸŽจ Theming - Customizable dark/light themes for the IDE

Requirements

  • Operating System: Windows 10/11 (64-bit) / Other platforms are enabled but not tested
  • Python: 3.9 or higher
  • Microsoft Excel: 2016 or later (with Office.js Add-in support)

Installation

pip install xpycode_master

Quick Start

  1. Install XPyCode:

    pip install xpycode_master
    
  2. Start the XPyCode Master server:

    python -m xpycode_master
    
  3. The Excel Add-in will be automatically registered.

    Open Excel and look for the XPyCode in Add-Ins -> More Add-Ins -> Shared Folder

  4. Launch in Excel:

    [Open Console] --> [<> Editor ]
    
  5. In XPyCode Editor

    • Add a python module: Right click on the workbook -> New Module
    • Start coding, using xpycode module:
    def updateExcelFromPython():
       import xpycode
       ws=xpycode.worksheets.getActiveWorksheet()
       rA1=ws.getRange("A1")
       rA1.values="Hello"
       rA1.format.fill.color="yellow"
    

Running as a Service

XPyCode can run as a system service for automatic startup:

# Install and start as a service
python -m xpycode_master service install

# Check status
python -m xpycode_master service status

# Stop service
python -m xpycode_master service stop

Supported on Windows, Linux (systemd), and macOS (launchd). See Service Management for details.

Upgrading

Check for and install updates:

# Check if an update is available
python -m xpycode_master --upgrade --check

# Upgrade interactively
python -m xpycode_master --upgrade

# Upgrade without confirmation
python -m xpycode_master --upgrade --yes

If XPyCode is running as a service, the upgrade process will automatically stop and restart the service.

Addin Hosting Modes

XPyCode supports two modes for running the Excel add-in:

External Mode (Default)

The add-in UI is served from https://addin.xpycode.com. This is the default mode and requires no certificate management.

python -m xpycode_master

Local Mode

The add-in UI is served from a local HTTPS server on your machine. Requires self-signed certificates.

python -m xpycode_master --use-local-addin

!!! warning "Mode Switch Cache Clearing" When switching between local and external modes, XPyCode will automatically clear the Office add-in cache. This affects all Office add-ins, not just XPyCode. You may need to restart Excel after switching modes.

Usage

Running Python Code

  1. Open a workbook in Excel
  2. Click "Open Console" in the XPyCode ribbon
  3. Open Editor with "<>" button
  4. Right click on the workbook name and add a python module
  5. Write Python code in the editor
  6. Press F5 or click "Run" to execute

Publishing Custom Functions

# In your module, define a function
def add_numbers(a: float, b: float) -> float:
    """Add two numbers together."""
    return a + b

Then use the Function Publisher in the IDE to expose it as an Excel formula: =ADD_NUMBERS(A1, B1)

Package Management

  1. Open the Package Manager panel in the IDE
  2. Search for a package (e.g., "pandas")
  3. Select version and optional extras
  4. Click "Install/Update" to install for the current workbook

Configuration

Configure themes, pypi urls, console preferences, ... in File/Settings menu

Excel Sample

You will find an Excel workbook sample in xpycode_master\excel_sample.

Dependencies

Core Dependencies

  • fastapi >= 0.100.0 - Web framework for the Business Layer API
  • uvicorn >= 0.22.0 - ASGI server for FastAPI
  • websockets >= 12.0 - WebSocket client/server implementation
  • aiohttp >= 3.8.0 - Async HTTP client for package index queries
  • packaging >= 21.0 - Version parsing and specifier handling
  • PySide6 >= 6.5.0 - Qt bindings for the IDE GUI (includes WebEngine for Monaco Editor embedding)
  • jedi >= 0.19.0 - Python autocompletion and static analysis
  • orjson >= 3.9.15 - Fast JSON serialization (recommended)
  • keyring >= 24.0.0 - Secure credential storage for AI providers
  • unearth >= 0.14.0 - Enhanced package discovery

Architecture

XPyCode consists of several interconnected components:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   Excel Add-in  โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚  Business Layer โ”‚โ—„โ”€โ”€โ”€โ–บโ”‚   Python IDE    โ”‚
โ”‚   (Office.js)   โ”‚     โ”‚    (FastAPI)    โ”‚     โ”‚   (PySide6)     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                 โ”‚
                                 โ–ผ
                        โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                        โ”‚  Python Kernel  โ”‚
                        โ”‚  (per workbook) โ”‚
                        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  • Excel Add-in: Office.js-based add-in providing the Excel interface
  • Business Layer: FastAPI server acting as message broker between components
  • Python Kernel: Per-workbook Python execution environment
  • Python IDE: PySide6-based development environment with Monaco Editor

License

This project is licensed under the MIT License with Commons Clause.

You are free to use, modify, and distribute this software for any purpose. However, you may not sell the software or include it as a substantial part of a commercial product or service.

See the LICENSE file for full details.

Author

BGE Advisory

Feedbacks

Contributions are welcome! Please feel free to submit issues.

Support

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xpycode_master-0.2.0.tar.gz (10.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

xpycode_master-0.2.0-py3-none-any.whl (9.8 MB view details)

Uploaded Python 3

xpycode_master-0.2.0-cp314-cp314t-win_amd64.whl (11.3 MB view details)

Uploaded CPython 3.14tWindows x86-64

xpycode_master-0.2.0-cp314-cp314t-win32.whl (11.0 MB view details)

Uploaded CPython 3.14tWindows x86

xpycode_master-0.2.0-cp314-cp314-win_amd64.whl (11.0 MB view details)

Uploaded CPython 3.14Windows x86-64

xpycode_master-0.2.0-cp314-cp314-win32.whl (10.8 MB view details)

Uploaded CPython 3.14Windows x86

xpycode_master-0.2.0-cp313-cp313-win_amd64.whl (11.0 MB view details)

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.2.0-cp313-cp313-win32.whl (10.8 MB view details)

Uploaded CPython 3.13Windows x86

xpycode_master-0.2.0-cp312-cp312-win_amd64.whl (11.0 MB view details)

Uploaded CPython 3.12Windows x86-64

xpycode_master-0.2.0-cp312-cp312-win32.whl (10.8 MB view details)

Uploaded CPython 3.12Windows x86

xpycode_master-0.2.0-cp311-cp311-win_amd64.whl (11.1 MB view details)

Uploaded CPython 3.11Windows x86-64

xpycode_master-0.2.0-cp311-cp311-win32.whl (10.8 MB view details)

Uploaded CPython 3.11Windows x86

xpycode_master-0.2.0-cp310-cp310-win_amd64.whl (11.1 MB view details)

Uploaded CPython 3.10Windows x86-64

xpycode_master-0.2.0-cp310-cp310-win32.whl (10.8 MB view details)

Uploaded CPython 3.10Windows x86

xpycode_master-0.2.0-cp39-cp39-win_amd64.whl (11.1 MB view details)

Uploaded CPython 3.9Windows x86-64

xpycode_master-0.2.0-cp39-cp39-win32.whl (10.9 MB view details)

Uploaded CPython 3.9Windows x86

File details

Details for the file xpycode_master-0.2.0.tar.gz.

File metadata

  • Download URL: xpycode_master-0.2.0.tar.gz
  • Upload date:
  • Size: 10.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for xpycode_master-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9f527d24aebcb00649e61275e42f0138e21d22f623e2e4b67f56cdbebda4a4ee
MD5 6c0433c04c94ad4b685fed5f947535da
BLAKE2b-256 458867767915ec9bd875a0945b576175ad706f7a628a92a5c6af79ed94bb217b

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: xpycode_master-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for xpycode_master-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abdce8a8d6c713b0f9be6eacf34629253197ede2293bbb66547bb85e65ab96f3
MD5 bd57da8ad88a480e0d67a569ba661298
BLAKE2b-256 fd06fd55df36d388a7a261086ad3fcaab4b485282a1f9c6a9a2e3a835ee7981b

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp314-cp314t-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 ad6852a3094ad0c1619aba80e4b3a8573047c57bd488e2c1bb954af26443b372
MD5 81049bb166b12aae657a97dc2fef484d
BLAKE2b-256 4f36bb39ed586967a98c3e92fe8ecfc92b02a9c5358a9fff88fc357a29257f4c

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp314-cp314t-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 ca0b33be0050482059d19c3bfaddc925878e07a279603f87e2c5c7912f0b41f8
MD5 f62489f504f89645fc19ae9de681cae2
BLAKE2b-256 fd94ce8933c06e674f8608583338a2be36a94e829deaea189b09ff9eb5fba02a

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ce68f70f824b8eed404e55bcef57283ab91a2e5c7acd7ee4187e7b16da7eeb55
MD5 7b420a6d1302a6bc6a0b9166080d29cc
BLAKE2b-256 66c38a728340dc8c36904f8749ae6975f95153e2d69cc7457835d5fc534c4fa6

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp314-cp314-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 2dd927ab16d8260abcd4a1adacfee930194f9a534742ee77f573c74043230b04
MD5 6a6da61966185948480db4b18fe177eb
BLAKE2b-256 310563fdf56d07ce24ea583834d81d6a2b26dc6a783bdade2a8278f87d89785f

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ec8b341d028550ba4bbe331e38d391d626d6252427daa3b3b9a7b4f61c061502
MD5 bec27dcc965a7959e4db550c885b8e5d
BLAKE2b-256 010fac0b1c45cf6fb93721b842dff0cb3548c09a14a770c9e43a55aad16b672c

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 6ce89a531d93052e91cf2e0d9b6332f4e4e6dd9710f1e9af173c1d671c7b0063
MD5 e5329176969ebb77ad9a277c23d7ae70
BLAKE2b-256 08151c232c648abfb3f89776ab447cfef4403931e229159e6b23a672e908c3d4

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4387c9e235234513275391f16110f1aa6285a12f0372179f75c479044099bf86
MD5 0cd0828d28935eb09db89e878309eaec
BLAKE2b-256 d2c4e0034e57d2845ca883c7af7347fc01c1eb9f6fa43a1cc9cbc820e5a4d974

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 1da502baea747274f0deaf3e9c01c111418f65dddbcf35169329258af6a7cfcf
MD5 5cf528a7cd9efe7b09019e980a4d809a
BLAKE2b-256 d3d7f65d71d039517ca1e93100905cf012413499974ca7879c46e6b1a34defdd

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a29d9de209667297b3a90aded1b9cfe2d875816d6c6d261f6a05dc7c6f9eaae8
MD5 a7cea6c3b1eddf8cfb8a476ab30ce02e
BLAKE2b-256 59a9cc8955f801b877e9bd538d97a19d85dde9d5a199d98feb4e6346b2416ff8

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 1f8e9028f9e847c87f7e3a63bebe1c89286b942ddab1758eee53d1d46086acb5
MD5 50f8232b1751bfde56ac077b58944d40
BLAKE2b-256 24c5e66d8905683a271b7eb026f416bc7f7a588c570b20d4fa6efde22923d2cc

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5457997adbc7f4ed0f35b8d439e4b3e8d17743dfb45368a4cac54e1b5d4c1fda
MD5 1d25b7308a946443593bf8cf60b770d3
BLAKE2b-256 27d81c1c45a76281b79e3c7603155480f749524ed1272cc2fa6da6ba4d63b3af

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7e0105bcba29c718e2f25eff716df70434742fb7cb19636617aac4e2666814fd
MD5 3813e169e9889c92e15019d3f59e3632
BLAKE2b-256 d61e86a6adc917b943819ac61ce50a674f83a5a36d2ba0fbee1adf937bbd954e

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for xpycode_master-0.2.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 27948c5819c8dc95bd07d4ceb50143b430a47cc101e85280223828529e2be6d4
MD5 a720afe9e42f37dbb471c8512debf5de
BLAKE2b-256 f17ea1cbd21cdc40d1a8af2ff6f206379ed3385680568b796532a67143201c25

See more details on using hashes here.

File details

Details for the file xpycode_master-0.2.0-cp39-cp39-win32.whl.

File metadata

  • Download URL: xpycode_master-0.2.0-cp39-cp39-win32.whl
  • Upload date:
  • Size: 10.9 MB
  • Tags: CPython 3.9, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for xpycode_master-0.2.0-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 560131a5af5f50b81dcc73395a3c2853a94d30cad00d2e88f7f255d45b241ce4
MD5 262898d21f6d3098eba5bab227bfa9ec
BLAKE2b-256 fc86a156d1a72aae2e2be910abd4a873a24c22fb5fc5a150acba1942bd7a1eba

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page