Python library for seamless bidirectional communication between Python and Excel across Windows and macOS platforms.
Comprehensive CLI for project setup, VBA integration, Excel add-in management, and deployment operations. The xlwings CLI provides powerful tools for managing xlwings projects, automating Excel workflows, and deploying Python-Excel solutions.
Commands for creating and managing xlwings projects with proper structure and configuration.
# Core project commands
xlwings quickstart <project_name> # Create new xlwings project
xlwings quickstart <project_name> --standalone # Create standalone project
xlwings quickstart <project_name> --addin # Create add-in project
# Project configuration
xlwings config create # Create configuration file
xlwings config show # Show current configuration
xlwings config set <key> <value> # Set configuration valueCommands for installing, managing, and distributing Excel add-ins.
# Add-in installation and management
xlwings addin install # Install xlwings Excel add-in
xlwings addin remove # Remove xlwings Excel add-in
xlwings addin status # Show add-in installation status
xlwings addin install --file <path> # Install custom add-in file
xlwings addin update # Update existing add-in
# Add-in development
xlwings addin build # Build add-in for distribution
xlwings addin sign <certificate> # Sign add-in with certificateCommands for executing Python code from Excel and managing the integration.
# Python execution from Excel
xlwings runpython <script> # Run Python script from Excel
xlwings runpython <script> --book <path> # Run with specific workbook
xlwings runpython <script> --show # Show Excel during execution
# UDF server management
xlwings udf serve # Start UDF COM server (Windows)
xlwings udf install # Install UDF dependencies
xlwings udf update # Update UDF registrationCommands for running xlwings REST API server for web-based Excel automation.
# REST API server
xlwings restapi run # Start REST API server
xlwings restapi run --host <host> # Specify server host
xlwings restapi run --port <port> # Specify server port
xlwings restapi run --debug # Run in debug mode
xlwings restapi config # Show REST API configurationCommands for managing xlwings PRO licenses and authentication.
# License management
xlwings license activate <key> # Activate PRO license
xlwings license deactivate # Deactivate current license
xlwings license status # Show license status
xlwings license info # Show license information
# Authentication (for xlwings Server)
xlwings auth login # Login to xlwings Server
xlwings auth logout # Logout from xlwings Server
xlwings auth status # Show authentication status
xlwings auth token # Show current auth tokenCommands for embedding, extracting, and managing VBA code within xlwings projects.
# VBA code operations
xlwings code embed <book> # Embed Python code in Excel file
xlwings code extract <book> # Extract Python code from Excel
xlwings code sync <book> # Sync code between Python and Excel
xlwings code clean <book> # Clean embedded code from Excel
# VBA development support
xlwings vba edit # Enable VBA live editing
xlwings vba import <module> # Import VBA module
xlwings vba export <module> # Export VBA moduleCommands for building, packaging, and deploying xlwings projects.
# Project building
xlwings release # Build project for release
xlwings release --include-excel # Include Excel files in release
xlwings release --standalone # Create standalone executable
xlwings release --target <platform> # Build for specific platform
# Distribution
xlwings pack # Package project for distribution
xlwings pack --format zip # Package as ZIP archive
xlwings pack --format installer # Create Windows installerCommands for copying templates, configurations, and project assets.
# Template operations
xlwings copy template <name> # Copy built-in template
xlwings copy config # Copy configuration template
xlwings copy vba # Copy VBA modules
xlwings copy addin # Copy add-in files
# Custom templates
xlwings template create <name> # Create custom template
xlwings template list # List available templates
xlwings template install <path> # Install custom templateCommands for development workflow, debugging, and troubleshooting.
# Development support
xlwings dev install # Install development dependencies
xlwings dev test # Run project tests
xlwings dev lint # Lint Python code
xlwings dev format # Format Python code
# Debugging and diagnostics
xlwings debug info # Show system and version info
xlwings debug engines # List available Excel engines
xlwings debug config # Validate configuration
xlwings debug permissions # Check file permissionsxlwings quickstart myprojectCreates a new xlwings project with this structure:
myproject/
├── myproject.py # Main Python module
├── myproject.xlsm # Excel workbook with xlwings setup
├── xlwings.conf # Project configuration
└── README.md # Project documentationOptions:
--standalone: Creates standalone project without Excel dependency--addin: Creates Excel add-in project structure--template <name>: Use custom project template# Create default configuration
xlwings config create
# Set interpreter path
xlwings config set interpreter /path/to/python
# Set PYTHONPATH
xlwings config set pythonpath /path/to/modules
# Show all configuration
xlwings config showConfiguration file format (xlwings.conf):
[xlwings]
INTERPRETER = python
INTERPRETER_MAC = python
PYTHONPATH =
LOG_FILE =
SHOW_CONSOLE = False
LICENSE_KEY =# Start server with default settings
xlwings restapi run
# Custom host and port
xlwings restapi run --host 0.0.0.0 --port 8080
# Debug mode with auto-reload
xlwings restapi run --debug --reloadREST API endpoints:
GET /docs - API documentationPOST /execute - Execute Python codeGET /books - List open workbooksPOST /books/{book}/sheets/{sheet}/range - Range operations# Embed Python code in Excel file
xlwings code embed myproject.xlsm
# Extract embedded code for editing
xlwings code extract myproject.xlsm
# Sync changes back to Excel
xlwings code sync myproject.xlsm# Activate PRO license
xlwings license activate XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
# Check license status
xlwings license status
# Deactivate license
xlwings license deactivatexlwings CLI respects these environment variables:
# Core configuration
XLWINGS_LICENSE_KEY=<license_key> # PRO license key
XLWINGS_LOG_FILE=<path> # Log file location
XLWINGS_CONFIG_DIR=<path> # Configuration directory
# Development settings
XLWINGS_DEBUG=1 # Enable debug mode
XLWINGS_NO_DEPS=1 # Skip dependency installation
XLWINGS_MOCK=1 # Use mock Excel for testing
# Server settings
XLWINGS_SERVER_URL=<url> # xlwings Server URL
XLWINGS_SERVER_TOKEN=<token> # Server authentication token# GitHub Actions example
name: xlwings-project
on: [push, pull_request]
jobs:
test:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: '3.9'
- name: Install xlwings
run: pip install xlwings
- name: Setup xlwings
run: xlwings config create
- name: Run tests
run: xlwings dev test
- name: Build release
run: xlwings release
if: github.ref == 'refs/heads/main'# Dockerfile for xlwings REST API
FROM python:3.9-slim
RUN pip install xlwings[all]
COPY . /app
WORKDIR /app
RUN xlwings config create
RUN xlwings license activate $LICENSE_KEY
EXPOSE 8080
CMD ["xlwings", "restapi", "run", "--host", "0.0.0.0", "--port", "8080"]#!/bin/bash
# deploy.sh - Automated deployment script
set -e
echo "Building xlwings project..."
xlwings release --include-excel
echo "Running tests..."
xlwings dev test
echo "Packaging for distribution..."
xlwings pack --format installer
echo "Deployment complete!"# CLI command types (conceptual)
CLICommand = str # Command name
CLIOption = str # Command option
CLIArgument = str # Command argument
# Configuration types
ConfigKey = str # Configuration key
ConfigValue = str # Configuration value
ConfigDict = dict[str, str] # Configuration dictionary
# Project structure types
ProjectName = str # Project name
ProjectPath = str # Project directory path
TemplateName = str # Template identifier
# Server types
ServerHost = str # Server hostname/IP
ServerPort = int # Server port number
APIEndpoint = str # REST API endpoint pathInstall with Tessl CLI
npx tessl i tessl/pypi-xlwings