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: Linux/macOS (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 an Alpha version, almost Beta.

๐Ÿšจ 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.1.8.tar.gz (65.4 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.1.8-py3-none-any.whl (65.3 MB view details)

Uploaded Python 3

xpycode_master-0.1.8-cp314-cp314t-win_amd64.whl (26.7 MB view details)

Uploaded CPython 3.14tWindows x86-64

xpycode_master-0.1.8-cp314-cp314t-win32.whl (26.4 MB view details)

Uploaded CPython 3.14tWindows x86

xpycode_master-0.1.8-cp314-cp314-win_amd64.whl (26.4 MB view details)

Uploaded CPython 3.14Windows x86-64

xpycode_master-0.1.8-cp314-cp314-win32.whl (26.2 MB view details)

Uploaded CPython 3.14Windows x86

xpycode_master-0.1.8-cp313-cp313-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.1.8-cp313-cp313-win32.whl (25.6 MB view details)

Uploaded CPython 3.13Windows x86

xpycode_master-0.1.8-cp312-cp312-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.12Windows x86-64

xpycode_master-0.1.8-cp312-cp312-win32.whl (25.6 MB view details)

Uploaded CPython 3.12Windows x86

xpycode_master-0.1.8-cp311-cp311-win_amd64.whl (25.9 MB view details)

Uploaded CPython 3.11Windows x86-64

xpycode_master-0.1.8-cp311-cp311-win32.whl (25.7 MB view details)

Uploaded CPython 3.11Windows x86

xpycode_master-0.1.8-cp310-cp310-win_amd64.whl (25.9 MB view details)

Uploaded CPython 3.10Windows x86-64

xpycode_master-0.1.8-cp310-cp310-win32.whl (25.7 MB view details)

Uploaded CPython 3.10Windows x86

xpycode_master-0.1.8-cp39-cp39-win_amd64.whl (25.9 MB view details)

Uploaded CPython 3.9Windows x86-64

xpycode_master-0.1.8-cp39-cp39-win32.whl (25.7 MB view details)

Uploaded CPython 3.9Windows x86

File details

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

File metadata

  • Download URL: xpycode_master-0.1.8.tar.gz
  • Upload date:
  • Size: 65.4 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.1.8.tar.gz
Algorithm Hash digest
SHA256 790f72945ab374ec27cb82b1651e55fc817632904c89180219f66df85667c959
MD5 0b81617b61ebd2f2c6d949cc98a9656d
BLAKE2b-256 117edacb1dd344a2ed44b858bc0fea34b2fb49fa1918c4cd24eea56ab5f4d6a0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 65.3 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.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 96a3712a4157fe40799a3269727a1de36f5cde3aec28293276bb4bf79eefc883
MD5 6ed21b1a77bda73ef17af73539d24c5b
BLAKE2b-256 13dd8f4ac3bdb1b2597999d42608c2fddab28dc158ab3e2d98bc93e735a3b8d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 79242817c1aee7e469f58dece997308687f60f45429c5626e53aa013e9f192a7
MD5 e9fa50c90fb12be590153dc2cd3af9ae
BLAKE2b-256 fb9344fa5faafee5b611a680024d75eb6862d68d080b529c7c872688b8d0b86f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 6c9696e9b459a7382a8d9af3c8962d1c7c472e5da3e4993ad1764be335df46ab
MD5 23ad63992d30635979f80ef12bc47aea
BLAKE2b-256 552e90286f5e2b6a401edbf01d0131a51f8a4724bef537399027da47966f9b1c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 a8875a0f100ae4adb293e2ffd662f0b2f65c6c02f48294a1acc0b429c87d5946
MD5 952a893092828db06666545343e685f6
BLAKE2b-256 32d126a4668defeb1ad1d5a2f75843112bb66879bbd2b899afd869f8799c06ac

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 96fbc8415ed86761302c421cc4cc6195f0778cd1e133e495fe80df0cd6036f84
MD5 aa83c47bff51959c100695ba84d462da
BLAKE2b-256 ccdb6f46d35a1dbce14f6522baa86f30fd078269a45355d9366de8aeee031df6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0b503861231244995905ed130ac7d5ee693171a39f3eee5c00a333bcc49a6290
MD5 5c00174b4a7325dcff7a0b0eb8e3fc3c
BLAKE2b-256 063ffba2774a7bef1c1c855c639b33235443ebf8d987621aee73a19ba01175a3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 d43a98635d3bcda9e5800b26e094d2ff9aeed15ff5cb78536593eafbf36292b6
MD5 6e20c47df11e69fad4e64b87d553e1c3
BLAKE2b-256 2f8258029c402ee6c046c374a0d2265af724c34d8356441c75e2f212abbf1b71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b57b9c592d1929107685609809f27bbc28d25b6f7915d687a7076767483f5b62
MD5 b0183c59f5c140c7e169d7ff51c1f045
BLAKE2b-256 feee2292815e856990aa891a01460a2a2928ea7aa6277b8476d3dd30d47a245c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 515f116ab4f234c059d968d5989ecde5609bb0786f8c4d3d7765879ee20c3a84
MD5 3240baa2f13908915a5efb4fd8570618
BLAKE2b-256 c77745daa796ef219aad86cef3721ef39304e163e86b366b84007a40521fc39f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7f4d3a4fc6da1f73d6bb4df83cccc620691546feca51ccc499fd4b0f4c204d68
MD5 072c732264e66f884954f86056587609
BLAKE2b-256 714f9aa8fe49aca799fe301fe2530603cdf599160d6662cdbaf3139ab020c833

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 367d7bf07eff89b6251d5e71c3bd687415686393367280eb3b6c541300c8e653
MD5 4dcb3263da8ae9cad82466e76a675e13
BLAKE2b-256 b48b2011d006c7b8ecd10c44d6c6afe357ae799e709cd23a460732cd46f833d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d2f53e8e85f32839ec321c21d81ed768318a2a215a5f6bce8794072a17f6fc3e
MD5 ef35ae96ae16d0807725eb75ed5f0141
BLAKE2b-256 ae3bcf5dff90578c7eac285c3183f3cd02deec82553bdc35a2bfc84ab19a8840

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 7000b32af91cdd10c33dba58540c50e4d972f9ff1700931fa33bebe2d3672bce
MD5 5b8ad02a9190fd226e8290ba163104dd
BLAKE2b-256 db0df5e189b1b2e683901454c5dc87b863968a568a1f7901830a02112127a1c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.8-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ecafcaf48ab4397830996290cfdb8b218699e7d614da99030232616b3dcbfbf4
MD5 dbccba31a43cad796810dd3271f4740c
BLAKE2b-256 95de26e480e51d84d5ff899af348ea58cae5fec75489bf1d01d6d0105f7db1f4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.8-cp39-cp39-win32.whl
  • Upload date:
  • Size: 25.7 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.1.8-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 524247ca131fef70afbe78e66133626eec3308393b0fe773b05f521a1abae857
MD5 fcd7cd848cb72893892fe86d9c422874
BLAKE2b-256 e40af015b811d44a96a8c306be176715ceeed68760bac4471e0b0b2ab088613a

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