Skip to main content

Excel-integrated brick structures and User Defined Functions (UDFs)

Project description

xlbricks

Excel-integrated brick structures and User Defined Functions (UDFs) for Python.

Overview

xlbricks is a Python package that provides a powerful framework for working with Excel through xlwings, offering:

  • Brick Data Structures: In-memory representation of Excel ranges as hierarchical key-value structures
  • Excel UDFs: Custom functions callable directly from Excel spreadsheets
  • QuantLib Integration: Financial calculations and analytics with QuantLib support
  • PyQt5 UI: Interactive explorers and editors for managing brick structures
  • Validation Framework: Robust input validation for Excel data

Features

  • XLBrick & XLBricks: Core data structures for organizing Excel data hierarchically
  • Excel Integration: Seamless bidirectional communication with Excel via xlwings
  • Front Stack Management: Manage multiple brick collections with undo/redo capabilities
  • Configuration Editor: GUI for managing xlbricks settings
  • Data Explorer: Visual interface for inspecting and navigating brick structures
  • Utility Functions: Helper functions for common Excel operations

Installation

Install xlbricks using pip:

pip install xlbricks

Requirements

  • Python 3.11 or higher
  • Microsoft Excel (for xlwings integration)
  • Windows operating system (required for xlwings Excel integration)

Dependencies

xlbricks automatically installs the following dependencies:

  • numpy - Numerical computing
  • pandas - Data manipulation and analysis
  • xlwings - Excel integration
  • PyQt5 - GUI components
  • QuantLib-Python - Financial calculations

Note: QuantLib-Python can be challenging to install on some systems. If you encounter issues, please refer to the QuantLib installation guide.

Quick Start

Using xlbricks in Excel

  1. Create an Excel workbook and set up xlwings:
import xlwings as xw
from xlbricks import xlbfunctions
  1. Use xlbricks UDFs in your Excel formulas:
=xlb_brick("mydata", A1:B10)
=xlb_get("mydata", "key1")

Using xlbricks in Python

from xlbricks.libs.xlbricks import XLBrick, XLBricks
import numpy as np

# Create a brick from data
data = np.array([[1, 2], [3, 4]])
brick = XLBrick(key="mydata", data=data)

# Create a collection of bricks
bricks = XLBricks(key="root")
bricks.bricks["mydata"] = brick

# Access brick data
print(brick.to_dict())

Configuration

After installation, configure xlbricks by editing the xlbricks.json file:

{
  "APPS_PATH": "C:\\path\\to\\your\\xlbricks\\applications",
  "INTERPRETER": "C:\\path\\to\\your\\pythonw.exe",
  "PYTHONPATH": "C:\\path\\to\\your\\python\\models",
  "CONTEXT": {
    "PythonFunctions": "myapp.python_function.context"
  }
}

You can also use the built-in configuration editor:

from xlbricks.ui.config_editor import show_config_editor
show_config_editor()

Excel UDF Functions

xlbricks provides several User Defined Functions for Excel:

  • xlb_brick(key, data, persist=True) - Store Excel range as a brick
  • xlb_get(key, *path) - Retrieve data from a brick
  • xlb_delete(key) - Delete a brick
  • xlb_explorer() - Open the brick explorer GUI
  • xlb_config() - Open the configuration editor

Development

Running Tests

pytest xlbricks/tests/

Installing from Source

git clone <repository-url>
cd xlbricks
pip install -e .

Development Dependencies

pip install -e .[dev]

Project Structure

xlbricks/
├── libs/           # Core functionality
│   ├── xlbricks.py           # Brick data structures
│   ├── xlfunctions.py        # Function implementations
│   ├── validation.py         # Input validation
│   └── utility_functions.py  # Helper utilities
├── ui/             # PyQt5 GUI components
│   ├── explorer.py           # Brick explorer
│   ├── config_editor.py      # Configuration editor
│   └── tree_model.py         # Tree view models
├── tests/          # Unit tests
└── xlbfunctions.py # Excel UDF entry points

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

julij.jegorov

Contributing

Contributions are welcome! Please feel free to submit issues or pull requests.

Support

For issues, questions, or contributions, please visit the project repository.

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

xlbricks-0.1.0.tar.gz (718.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xlbricks-0.1.0-py3-none-any.whl (720.3 kB view details)

Uploaded Python 3

File details

Details for the file xlbricks-0.1.0.tar.gz.

File metadata

  • Download URL: xlbricks-0.1.0.tar.gz
  • Upload date:
  • Size: 718.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/1.0.0 urllib3/1.26.6 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8

File hashes

Hashes for xlbricks-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d9c115090d9e0b9c31d4761c975a4be3d9e26502d1aa4f9a49cbf4da6ea1cb6a
MD5 4aa47256ec03ed10cf1af7ae0cd0c707
BLAKE2b-256 0ba05bbd4dfa59ef03a7a10bb3da7e7d6c2b6b4123409da86946a3586465cb95

See more details on using hashes here.

File details

Details for the file xlbricks-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: xlbricks-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 720.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.10.0 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/1.0.0 urllib3/1.26.6 tqdm/4.62.3 importlib-metadata/4.8.3 keyring/23.4.1 rfc3986/1.5.0 colorama/0.4.4 CPython/3.6.8

File hashes

Hashes for xlbricks-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa73802a78429c8afc5573884c8ecfb6f3c06f1b93addfea787c480c70aa4db0
MD5 f13a50974b39297cd170ecfbd05a3414
BLAKE2b-256 674269b8db5e612c4fac7e166a8750c689fcb72c5fcc3ed1db99b6d7a851d595

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