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.6.tar.gz (65.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.1.6-py3-none-any.whl (65.3 MB view details)

Uploaded Python 3

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

Uploaded CPython 3.14tWindows x86-64

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

Uploaded CPython 3.14tWindows x86

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

Uploaded CPython 3.14Windows x86-64

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

Uploaded CPython 3.14Windows x86

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

Uploaded CPython 3.13Windows x86-64

xpycode_master-0.1.6-cp313-cp313-win32.whl (25.5 MB view details)

Uploaded CPython 3.13Windows x86

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12Windows x86

xpycode_master-0.1.6-cp311-cp311-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.11Windows x86-64

xpycode_master-0.1.6-cp311-cp311-win32.whl (25.6 MB view details)

Uploaded CPython 3.11Windows x86

xpycode_master-0.1.6-cp310-cp310-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.10Windows x86-64

xpycode_master-0.1.6-cp310-cp310-win32.whl (25.6 MB view details)

Uploaded CPython 3.10Windows x86

xpycode_master-0.1.6-cp39-cp39-win_amd64.whl (25.8 MB view details)

Uploaded CPython 3.9Windows x86-64

xpycode_master-0.1.6-cp39-cp39-win32.whl (25.6 MB view details)

Uploaded CPython 3.9Windows x86

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6.tar.gz
  • Upload date:
  • Size: 65.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.1.6.tar.gz
Algorithm Hash digest
SHA256 46a7aebc7a28d3e2a54abe593e52b33bfdcecff1ddc7b801b08ce919e17d5bf2
MD5 5b55c29c8e82c16ad72230d3c415d022
BLAKE2b-256 4aecca5137febbd982d18c47d18a8c6ec8d40aab1815c6791fd97a6f46957c0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2d02e2a748a7e0ed18d3bd3faa9999f8232420a1063c61511b0e1bee8b6fcdf5
MD5 bb0705fedbef76d7de64dc6d7f6b4b4e
BLAKE2b-256 e94202c1243ff772e675fbc61185ca944e66b0e8b9a09b4981eac302aa5ec15b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp314-cp314t-win_amd64.whl
Algorithm Hash digest
SHA256 8e789b01dc5520e3300e2830059ab7e82cc655c70b5ffbf4139e0b0d20a9e07b
MD5 ef7ee04f842300625b77567215dc76a0
BLAKE2b-256 4e053935dfb0f33af05d10d957b8155b39fbc691684e745facaa2ca5773b9e77

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp314-cp314t-win32.whl
Algorithm Hash digest
SHA256 bd374ac5cb168a9fbd8b52bc189e123c4122bc3465d559f90a4e9ae14ce8f069
MD5 6c65933604e05f5e36461ca0947b53c4
BLAKE2b-256 da1d1261653ba5c0ad022dcc048306b86f270ab04c41d2385542c299cac3aefa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 73d91e905d5bed24c0fd9b27583a9d96e9650ba4df5dc9d82008b1794b845567
MD5 045539e7d3fa8587e57813ff119488c2
BLAKE2b-256 bc0d8faa4289393d220e0af18c7b61f5c5bc2138f09c4aa84920000fcd10a322

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp314-cp314-win32.whl
  • Upload date:
  • Size: 26.1 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.6-cp314-cp314-win32.whl
Algorithm Hash digest
SHA256 ae1446520a0cfc2623ed81df484e63f89c0a7926956feac56866dd0345cb4734
MD5 e510170a0d05ba942cc950566c69be90
BLAKE2b-256 f35eecf3acf417bb0dc36e6df440f055b3ff088dd235b1d81b09aee1663e2114

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 b0550f54a271aa6079a0e8632c08c1e06e439f13213588782ab9c9b348034f03
MD5 1a82606231f1d2928ae545b9c9cad5a8
BLAKE2b-256 f54a70e530cdfe10547a4f02b1cf7783cbb1323c73f71bace640b8d2b2891689

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp313-cp313-win32.whl
  • Upload date:
  • Size: 25.5 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.6-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 bc9d02da546f693b9425bb334010acf176389e8b09503f2514bff154c08a1f62
MD5 64a80e41584fed36081e47f80ddb3cfe
BLAKE2b-256 5d1f2858ddaa6d30302efb9e5472914eac9a30681a4468d73c93ccc0740fa63c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 83d47860991aaae7fded3d73a245d09102a6fcc36c982056d1349683c2986367
MD5 d5338cf8528250398a4312fb30da2d19
BLAKE2b-256 afbeaf4ac1613abe5d1bec41162a81e0374ab7414fb7323756a1f16959b0bd1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp312-cp312-win32.whl
  • Upload date:
  • Size: 25.6 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.6-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 fade0e42457b0417e17b29e3f9a75033f26ab2a7ad64aa92219339921bb4773a
MD5 4efe5ee2febfaa22494742cfa455676b
BLAKE2b-256 5bcdf34d7eef82d1d8498f9bc84699b0829151ffd06b939a2ec2d07fe3f856ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 afaaedd3446236dc022c8f3c2b981342547dc61211204571c5c8812e701ab6c5
MD5 28d84eeb757258b1900ebcd9143a4b3a
BLAKE2b-256 a3fba320951a3153943a4984c7e236cb6b2b96774e55d4113fe6a9d424a364c4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp311-cp311-win32.whl
  • Upload date:
  • Size: 25.6 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.6-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 2765398410578095b0ad0997200dcd8a12e89b69120f4f76e6c2a214feb09273
MD5 a68e5ff65a643148fbfb051e3d16a4d6
BLAKE2b-256 39f172bd597d895647ee5df1d27ad1516ed3bcacb3be36ef8920837d0e9fd2a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 6376420175480b8fda140ff63732a8fad08ff655e52ae39e8652a04c426dd02a
MD5 27f267c46791e15b7f53fc67cbed14a8
BLAKE2b-256 e7df1dcd9837859be9aab82bb7bc14bf4e81a013ae9a7a685cac80b981623a2d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp310-cp310-win32.whl
  • Upload date:
  • Size: 25.6 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.6-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 77838c90ca6931a09cf12b9651c594dc1c93ce3d873868ed6496eecb30a93ca1
MD5 03f510021d3d8111ab4ac848fa97f80b
BLAKE2b-256 b4aa30d83358173155b997325796e3a4a91c1f45deb1c8ac2863d6fed25f5244

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for xpycode_master-0.1.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c378ba4db46537d4b8f66f49d1a8361ad3a0a9442188d15b87063f5d8dd5d212
MD5 269f9341c471e30d76681f5124e6c8c4
BLAKE2b-256 daa49f0eff7ef00cbc37501110b23826c9e0c2e454927bdfba61d818133143ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: xpycode_master-0.1.6-cp39-cp39-win32.whl
  • Upload date:
  • Size: 25.6 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.6-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 0e28f9a5bb0210176d59a8cc790d81023d9ce5f41268bd215e4819603abc924c
MD5 5ee998b257311cc641c69e99a4d29dc1
BLAKE2b-256 d490f93e3e8addb29558401d4b77ead718a48eea7d55aa2e76d2f41491b166c9

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