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"
    

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.

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.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.5.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.5-py3-none-any.whl (65.1 MB view details)

Uploaded Python 3

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

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14tWindows x86

xpycode_master-0.1.5-cp314-cp314-win_amd64.whl (26.2 MB view details)

Uploaded CPython 3.14Windows x86-64

xpycode_master-0.1.5-cp314-cp314-win32.whl (26.0 MB view details)

Uploaded CPython 3.14Windows x86

xpycode_master-0.1.5-cp313-cp313-win_amd64.whl (25.6 MB view details)

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.1.5-cp313-cp313-win32.whl (25.4 MB view details)

Uploaded CPython 3.13Windows x86

xpycode_master-0.1.5-cp312-cp312-win_amd64.whl (25.6 MB view details)

Uploaded CPython 3.12Windows x86-64

xpycode_master-0.1.5-cp312-cp312-win32.whl (25.4 MB view details)

Uploaded CPython 3.12Windows x86

xpycode_master-0.1.5-cp311-cp311-win_amd64.whl (25.7 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11Windows x86

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10Windows x86

File details

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

File metadata

  • Download URL: xpycode_master-0.1.5.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.5.tar.gz
Algorithm Hash digest
SHA256 bb59b749ca59fce189c2645e997939e884abc52c99eeca37ad56759e9d523fc9
MD5 a6b78f5b048413c116dc2e7f0f0e1890
BLAKE2b-256 127894d3347bc7dd38c3bd03f7dd033a6aa455bdf15f09135d40e0a4ae23380c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 667884bc21c322db1f597809d49800a4b991b2c0c24759a968f4b3878fc837d4
MD5 02840c12bc90c7f055d13369a652d931
BLAKE2b-256 fcd2242c9ed23689ba1707bcf7c1e3f12357141c8cc2d59ba068f056c010d284

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 13d04a2b76882c7897d34a4109351fc2153b056525f47c780f77297ab2aa9051
MD5 16d8b725b5eca44320383aba5519169b
BLAKE2b-256 424faec5375f05c504e0773b7ba7433ebc8725f7019fd10dd36625664c148215

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 b5f13b681b416d0a00e2809039c0d413eeb50ce0004413ed0e2fe0bc63899a35
MD5 b44c3dee158170fba7237552768e4591
BLAKE2b-256 6d61c1badcc4968a578e3be87c136c025fba0411ec997885620dcd695e8b6236

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 c0f7ca1767134f9defa583c2b1f9661dcf0377e51478ab2951c53f75bb860066
MD5 410481fab78beed2b629ac63a813f256
BLAKE2b-256 f431775fcb8f0baefbd5f759742275d584ee3f156f88b51a90f8d07abc7356bd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 2ebbbf236d583a9d8bf60e90dcc363c3646fe52e1354364fe177d41cbc14a7c2
MD5 821982857abb473015bab8173812539b
BLAKE2b-256 3b74b43f05750fa37c80cfabe41d81b40889b896d6c942a1ba45c77a19434a06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7316e32c9cc59c4687fdfe3fc8157e88ed9163b2a4928095dd83e184c5e35dc2
MD5 7f0aadad021712f006257b6e26e18ac4
BLAKE2b-256 04984329e766d5c06ef20f0a814a19bfa7152466bb941aeae583e462e74425ab

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 978b2a5a83c94aed6e6522dfa6ae7262c6c738698e5c65071a07d085ae07b9e4
MD5 cdad78e87575dd6e6cf1f42d19222edb
BLAKE2b-256 4d5b1475139fa65a9ce1be917119054522c498427095e3f532cf26d7888043e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5bca664a24f779c53ac72b2608569c6346d0a4f9ca073542c0942f71e24624a3
MD5 34e62d258a12b4df984e503701a0c8a2
BLAKE2b-256 3c9dda809b781b67941c16a75da781569bd49f4c0c3ab7ba54c5fbb5998f9dd5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 468107c6c285d9cdd04db0b2b3a43fc47fcdce81f97f1b2db0f70e76a736f041
MD5 5b5d4748832aca11803f88889f50d64f
BLAKE2b-256 9406ff12bf2d53f03cc0cd48c7efe28f2a620526443954ce51bfa5c83a03e5cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cf89f11fc54e9d75aa34732e703190d2c6a98c153d1d7dccde19b72c6430f579
MD5 9ea2be86862aaea11f134d452ab8ecae
BLAKE2b-256 126647388bec36bbbd0bf1bcac0f19eb267a205e24a757d7a099a902abc34171

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 847c156212e173eef0376a74ea25f351a7d08783bdcc06caf8bd84d8f31d3045
MD5 30a8dd206fa8776204bbb96c1f0972c5
BLAKE2b-256 c3137861259751a94c326a84224d21a799448accf4ee83a9d8bfa7dbf1ea6ca2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 50e789a093fed70564b93096c7fe7168a3fc81bd52b39f0972c10da9cfd1f3e0
MD5 49a555d98f955d14c7df951c3ab39c02
BLAKE2b-256 f1f22e8bbddef3e7ee26ab6aaeec1d8db36b462c24e8c231a4581d5f23251a69

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.5-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 efc0c56d6838eda4792e1bdb7023147cc8288976f3ef1c6ad1fd152ee011e1da
MD5 d230bd9027410bc652a4e1b716234c8b
BLAKE2b-256 e493d4e24b379c6b845e186df2c4c724c4c9ccf296d6461bef21b421fb12f799

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