Skip to main content

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

Project description

XPyCode

Python 3.10+ 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.10 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"
    

Addin Hosting Modes

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

Local Mode (Default)

The add-in is served from a local HTTPS server on your machine. This is the default mode and requires no internet connection.

python -m xpycode_master

External Mode

The add-in is served from https://addin.xpycode.com. This mode is useful for easier setup as it doesn't require local certificate management.

python -m xpycode_master --use-external-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.0 - 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.3.tar.gz (64.9 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.3-py3-none-any.whl (65.1 MB view details)

Uploaded Python 3

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

Uploaded CPython 3.14tWindows x86-64

xpycode_master-0.1.3-cp314-cp314t-win32.whl (26.1 MB view details)

Uploaded CPython 3.14tWindows x86

xpycode_master-0.1.3-cp314-cp314-win_amd64.whl (26.1 MB view details)

Uploaded CPython 3.14Windows x86-64

xpycode_master-0.1.3-cp314-cp314-win32.whl (25.9 MB view details)

Uploaded CPython 3.14Windows x86

xpycode_master-0.1.3-cp313-cp313-win_amd64.whl (25.5 MB view details)

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.1.3-cp313-cp313-win32.whl (25.3 MB view details)

Uploaded CPython 3.13Windows x86

xpycode_master-0.1.3-cp312-cp312-win_amd64.whl (25.5 MB view details)

Uploaded CPython 3.12Windows x86-64

xpycode_master-0.1.3-cp312-cp312-win32.whl (25.3 MB view details)

Uploaded CPython 3.12Windows x86

xpycode_master-0.1.3-cp311-cp311-win_amd64.whl (25.6 MB view details)

Uploaded CPython 3.11Windows x86-64

xpycode_master-0.1.3-cp311-cp311-win32.whl (25.4 MB view details)

Uploaded CPython 3.11Windows x86

xpycode_master-0.1.3-cp310-cp310-win_amd64.whl (25.6 MB view details)

Uploaded CPython 3.10Windows x86-64

xpycode_master-0.1.3-cp310-cp310-win32.whl (25.4 MB view details)

Uploaded CPython 3.10Windows x86

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3.tar.gz
  • Upload date:
  • Size: 64.9 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.3.tar.gz
Algorithm Hash digest
SHA256 34a045cab5bf8d108570221f15ec188312c32b4c1753f35a070a3d8050c0cd53
MD5 0233c44fff70e60e13d6c9d6e9717c25
BLAKE2b-256 a64d7e22d032ec70fce0f8c9ac25cd0514f17d18b7d8f0deb6057a9358a96410

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 65.1 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c7bf36969fe8d9a148aa6f48b549140f3068ee66d6b17912de4e7bcc20de2b0b
MD5 b4219b46226962122ac0ad750c00782a
BLAKE2b-256 573bea76bd7de3916d797d9f2c51467f2809418e7e79fa3fe9fcb3d3fe1a7757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 78737c14debaffd72b3ab8aeea9b8501a5f9daee05ad61fbbf61908dfd5f0cba
MD5 ad3771156426cdda03f5ad74510b0565
BLAKE2b-256 0f9dc86dc4a2048e5f172412aa8512b2b15de4396553b3cd6c01519955705628

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 117fc961688925ada6abc087b3a66a3f14e79e992f9d43c007742b8ad01c2887
MD5 e7219cf0fc6818fd099c0136101b45cf
BLAKE2b-256 112675adcfb11b679ff8788d6ee4100034eb28e133884c8a8b20c52ca7b97f6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 76731a032128ff3af1f39ec6ce62d920ecd808637a8094720f299ea7135abe6a
MD5 df3d731098df99445b0026429c977526
BLAKE2b-256 79a521117d6b6a5bb095cb34185535d0519e67f5b00050e5037e8e96d6bab42e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-cp314-cp314-win32.whl
  • Upload date:
  • Size: 25.9 MB
  • Tags: CPython 3.14, 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.3-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 8ac21187706ced0f9475490e7dff07ea550d3035e39016a6a1ae612573cec968
MD5 9c80450952029a12b7e1379d9dc76c54
BLAKE2b-256 4321921758d35ef28e1198a4be738ed8820114d2fc0e8a5242306f094fe4bc86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 29561b62fca00355821ae21833dbbea58e6fbfda6acedd3da95171f9086425a4
MD5 7e181aa590232acd3984acdeae4e1adc
BLAKE2b-256 951dd7faf03a58d14d5a79cacc3a3129d6b2945c190567951e09e578d8353dac

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-cp313-cp313-win32.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.13, 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.3-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 9a9d600d6d7500946817d5c131d6a4ae4b527e7cbdee3bc0c65466be2058dddd
MD5 c3606653654d3ae5a49b9d384db9a791
BLAKE2b-256 02f700b9ff77448a59e5cbc8d81f0f0760c96f0df19bc5cce3b181ea46ff6682

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4ae8cc4f1f88b82fde9755a4000a665d2637e2d39d7c172c15cc48bf1a0c2b1f
MD5 5582ec6094dc9056e087cfaacf9ab792
BLAKE2b-256 c9a32d67f570be9eef1aaa74bd97498243a90968e297a7e45f272d7f177e2b06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-cp312-cp312-win32.whl
  • Upload date:
  • Size: 25.3 MB
  • Tags: CPython 3.12, 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.3-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 9893d37b184d79a73c39d4267fa8797b2cb0876e974329008e12d215e2b9ba14
MD5 3c44945a101c9b3fbf89878ef3129092
BLAKE2b-256 8d6cf432fe351aba7955e7fbb10a27ecccc5bf881929ccce0751db8f41929566

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3095f9b1f47284f875b05cbeeb376d8b90e96dc7432eb9c30ca0c6d8bf1ef477
MD5 61cf6901cb48da6ead1a4593f46d209f
BLAKE2b-256 8bff97766ef01decc0badba999cffcd9b48b6fb9000e13049d10baf19b4ccbaa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-cp311-cp311-win32.whl
  • Upload date:
  • Size: 25.4 MB
  • Tags: CPython 3.11, 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.3-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 c24ccb2d5d8859bc2c5ca43645fa2d19b54d59e2d71dd71b99ea4388e537828e
MD5 851149c7789b45de6ea2181f7b14039d
BLAKE2b-256 bb5ae9778121b45311386c44cc3640ea274e09f7026327f49c142700d896bd0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ac898291855bac2a3ed07d8ca6fbd92d38f7bc9c07cc919c98585968d650284e
MD5 21cd53b1f0e50aa508dbbf327ace8d31
BLAKE2b-256 dbebeb6e6b540581ebe92d5a39fe76edc84a2283567a9ee3cc917c0ac0efafa4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.3-cp310-cp310-win32.whl
  • Upload date:
  • Size: 25.4 MB
  • Tags: CPython 3.10, 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.3-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 13d48772cae80d916789cbc25ea7b7aa4a55439545f5bcef7549ae86de6909f2
MD5 e8c84c531a601310aaea13b0ff7f1b65
BLAKE2b-256 cffd329064e39b641bb9f7ffdceb4d13dbdf031ea66cd4084b6d41b01a513c64

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