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.9.tar.gz (65.6 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.9-py3-none-any.whl (65.5 MB view details)

Uploaded Python 3

xpycode_master-0.1.9-cp314-cp314t-win_amd64.whl (26.9 MB view details)

Uploaded CPython 3.14tWindows x86-64

xpycode_master-0.1.9-cp314-cp314t-win32.whl (26.5 MB view details)

Uploaded CPython 3.14tWindows x86

xpycode_master-0.1.9-cp314-cp314-win_amd64.whl (26.5 MB view details)

Uploaded CPython 3.14Windows x86-64

xpycode_master-0.1.9-cp314-cp314-win32.whl (26.3 MB view details)

Uploaded CPython 3.14Windows x86

xpycode_master-0.1.9-cp313-cp313-win_amd64.whl (26.0 MB view details)

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.1.9-cp313-cp313-win32.whl (25.7 MB view details)

Uploaded CPython 3.13Windows x86

xpycode_master-0.1.9-cp312-cp312-win_amd64.whl (25.9 MB view details)

Uploaded CPython 3.12Windows x86-64

xpycode_master-0.1.9-cp312-cp312-win32.whl (25.7 MB view details)

Uploaded CPython 3.12Windows x86

xpycode_master-0.1.9-cp311-cp311-win_amd64.whl (26.0 MB view details)

Uploaded CPython 3.11Windows x86-64

xpycode_master-0.1.9-cp311-cp311-win32.whl (25.8 MB view details)

Uploaded CPython 3.11Windows x86

xpycode_master-0.1.9-cp310-cp310-win_amd64.whl (26.0 MB view details)

Uploaded CPython 3.10Windows x86-64

xpycode_master-0.1.9-cp310-cp310-win32.whl (25.8 MB view details)

Uploaded CPython 3.10Windows x86

xpycode_master-0.1.9-cp39-cp39-win_amd64.whl (26.0 MB view details)

Uploaded CPython 3.9Windows x86-64

xpycode_master-0.1.9-cp39-cp39-win32.whl (25.8 MB view details)

Uploaded CPython 3.9Windows x86

File details

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

File metadata

  • Download URL: xpycode_master-0.1.9.tar.gz
  • Upload date:
  • Size: 65.6 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.9.tar.gz
Algorithm Hash digest
SHA256 3c22114ef39184fde06c2793f68670fb9ede3ab5f4aa21511d7440d5c6f65095
MD5 188cfab2444d4ab254f12b6753371025
BLAKE2b-256 e47e78acef255bff62317d4c3f6486e4afa707a3b458e503415f47a90f15054f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.9-py3-none-any.whl
  • Upload date:
  • Size: 65.5 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 be00c7f2c149b8566b8cab9fc66e62408c8b7dbbe29d1773928dd1bf438b2eda
MD5 a94b769fde6fafa608676e1c5bb4d688
BLAKE2b-256 f59178cb1ce6814ac63710d237b7160b184792ee0639a48f91346b8b9b3386b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 4e1c82c93248639abd22e8829d64bcca407ff589404f7b5d56d63f73d191d8fe
MD5 6595d34694c766a2362f6898de58b552
BLAKE2b-256 d14852a6b5c7be1e26b09ac0dc9fa810090474d72ea559d4b0f1e9557f3618bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 64e1d40e3f2341237441438e8b73731d55ce2cd92efbb7035be9e8bcb791e1c3
MD5 d9dd122219e2f93eeeb6850f51d364ae
BLAKE2b-256 9283edc756ecb07d6bfc8143e3452d04bae9d97533a9d12f1c472fa1da917d73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 de68e8de496337d75ceede1f018bed8b46ef314d32cbb8fbc0872254e22ee273
MD5 771247c94692006eb9640d3f18c5b2d2
BLAKE2b-256 de828f9edfc37623913236263cec945ac54d362f1cae809c89be47400c7ad717

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 685d4b443f24c8b07b8380a05c8017d69af3fa23f6f61a4ab7f1c07cde965264
MD5 22fc6da473dc321dbf819aa273adf73a
BLAKE2b-256 1c488fef21cb1b1c81ab175b9f587635c0267d68f77232f66c51514768aa3ee9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 452649475b18f3a004cb2b8f95064435eb2c9d9e1ed252dfc9daf2004b8ffdb4
MD5 5a6edd22ea23aefa7b12f7f9e4e513a1
BLAKE2b-256 f550b2bcd92cac9a0df677291a20d054c842e3391c3bbea6ee82d47124c14b3d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 15291b9888cb81465be31e66d1eb2f292ae99704a9bbea0f9de3d1851417680f
MD5 18d2fde121a9fdc859c55b06b2eec1b8
BLAKE2b-256 215738349bc6b41a42aa34be3b08b6bc4d19296433a918a39327c6e1a30ac39f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 afc59b64f384d488c759f113ec9372a2904654d5c3abd9be0714a02b761421fc
MD5 0aaacfb5673381def1ca7547bfb300cb
BLAKE2b-256 a270fd5d98ec91b1afd698748f92db8d44d6ccbeb7add8541ff50379ad52eb85

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 7948b9f71099ce76ad562e65191700ef5f441a83488417296392f6009f861d08
MD5 9fc453ce375e3a0e1b17af2db0ddb7e1
BLAKE2b-256 0775e4b6daffbd62bc01d913a209c1b8625fe81ab64506f077517f107869c04d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cc6436a99bb544a657f50ba0150306147342f79f6050791e69e8e800ffb8a190
MD5 a62a64bbc42e286a6fea9f73ce775bb8
BLAKE2b-256 28fd1bcc7eb0984215cbae764308ec0ba58b205834bd92269d4bdedf7ca528bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 b206f304eb332beb6386b8c26c0f119686a8d47f21b8ab0cfc2d07309a4bf38e
MD5 52270a240cc61638bf2c90979d2d4d6c
BLAKE2b-256 0f66c63913c0b1a0b5b0d0281c31a73e6e4a0294bd830e72bb547905d4c34554

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 52378838f85e27cc8c4d5dbadcb8679fd44e1e463bfc4addf22b02060f9de04e
MD5 21da7a1164aa66d455a3bde2409e9d98
BLAKE2b-256 9e7d3b69855227f224e39959635d4518f639ec947905457c37775e63ddb602d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 d35df82482a4d634980de48254de22f93797e079d1928225cc7006c04f3e4203
MD5 836bc4285291d1dd655a5726c5c31516
BLAKE2b-256 e2d9575855cd48fe675ce5a89cab6e109f61e31936b44aad8ef2b83dfb715cde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 aaeb80b928fe80591cbace919452defdf1e242b42f21fe23492e5a961fa003a7
MD5 a71f4490fce19d535e8991a7eba0eed2
BLAKE2b-256 01309b15bd1b040fe1fea01203012d631829d7cb38178357720da7674f12f2df

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.9-cp39-cp39-win32.whl
  • Upload date:
  • Size: 25.8 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.9-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 86ef976fb4d7ee7ddb0bce2c27ebc8d6fe37b42d5a1a14a85ff180db06151dd3
MD5 bfe7182965d6bc4fd0993d617b787433
BLAKE2b-256 18304e7502c07aba32f347956e280a3b52009bcc055480433d1b91ae4f9d8fdf

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