A Python library for writing calculations to Excel while preserving formulas.
Project description
Gridient
A Python library designed to simplify writing complex calculations and data structures to Excel files while preserving the underlying formulas. Define your logic in Python using familiar operators and let Gridient translate it into live Excel formulas.
Features
- Define calculations using Python operators (+, -, *, /).
- Write Pandas DataFrames and Series.
- Create parameter tables.
- Apply cell styling (bold, italics, colors, etc.).
- Use custom number formatting.
- Organize output across multiple sheets using a layout system.
- Best-effort column auto-width adjustment.
Installation
pip install -r requirements.txt
pip install .
Basic Usage (Conceptual)
import gridient as gr
import pandas as pd
# Define values and parameters
initial_investment = gr.ExcelValue("Initial Investment", 1000000, format="$#,##0")
discount_rate = gr.ExcelValue("Discount Rate", 0.05, format="0.00%")
params = gr.ExcelParameterTable("Parameters", [initial_investment, discount_rate])
# Perform calculations (these become Excel formulas)
revenue = gr.ExcelSeries.from_pandas(pd.Series([100, 150, 200]), name="Revenue")
profit = revenue * 0.2
profit.name = "Profit"
profit.format = "$#,##0"
# Create layout
workbook = gr.ExcelWorkbook("report.xlsx")
layout = gr.ExcelLayout(workbook)
sheet1 = gr.ExcelSheetLayout("Dashboard")
# Add components to layout
sheet1.add(params, row=1, col=1)
sheet1.add(profit, row=5, col=1)
# Add sheet to workbook layout and write
layout.add_sheet(sheet1)
layout.write()
TODO
- Parameters should have an option to provide a name. Such parameter shuld than be referenced by name in formulas. There should be a unique-ness check.
- Check rules for parameter names.
- Add themes: The user would pick a theme and it would style tables and values accordingly.
- Support for directly touching the xlsxwriter API.
- Support for hooks. Such that user can override internal data structures at any step of the process.
- Bug: There is an extra parenthesis in for example
=IF((B1>0),1,0)which should not be there.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gridient-0.1.3.tar.gz.
File metadata
- Download URL: gridient-0.1.3.tar.gz
- Upload date:
- Size: 45.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1c91ebcd10e609225da629a0c4ac8362840bee2310bc32f2da0ef5c91e671140
|
|
| MD5 |
c3381adf1522f6caa06ba3c0e4c3e84f
|
|
| BLAKE2b-256 |
ecf10a208f97390c343e088252a7493b644cc28cae53b439053599e0ab0b9626
|
File details
Details for the file gridient-0.1.3-py3-none-any.whl.
File metadata
- Download URL: gridient-0.1.3-py3-none-any.whl
- Upload date:
- Size: 21.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8818eb8997edc328519c25f4db70215a78352d023f9682e0b2405b54ec317ace
|
|
| MD5 |
23f2a78b0b5a983c1e36552cc9f5e602
|
|
| BLAKE2b-256 |
0a2138dd80af983b12ef524e3f1c93e31af6e562f0eca0693cd0b2062e6ceeb5
|