Skip to main content

Easy-to-use Python library for accessing computed Excel cell values

Project description

calc-workbook

PyPI Version Python Versions

calc-workbook is an easy-to-use Python library that loads Excel files, computes all formulas using the formulas engine, and provides a clean, high-level API to access computed cell values from each sheet.

Overview

openpyxl is the most common Python package for reading and writing Excel files; however, it does not calculate cell formulas.
The formulas package adds support for evaluating a large set of Excel formulas, but it does not provide a straightforward interface to retrieve the computed values per sheet.

calc-workbook bridges that gap by exposing a simple interface with two core classes:

  • CalcWorkbook – loads and computes the workbook, providing access to individual sheets.
  • CalcSheet – provides access to computed cell values and sheet metadata.

Installation

pip install calc-workbook

Example File

A B
1 10 5
2 20 15
3 =A1+A2 =B1*B2

Example Code

from calc_workbook import CalcWorkbook

# Load workbook and compute formulas
wb = CalcWorkbook.load("example.xlsx")

# List available sheets (in lowercase)
print(wb.get_sheet_names())

# Access a specific sheet in lowercase
sheet = wb.get_sheet("sheet1") 
# Access first sheet
sheet = wb.get_sheet() 

# Retrieve computed values
print("A1:", sheet.cell("A1"))        # 10
print("A1:", sheet.cell([1, 1]))      # 10
print("A2:", sheet.cell("A2"))        # 20
print("A3:", sheet.cell("A3"))        # 30

# Get sheet dimensions
print("Rows:", sheet.rows())          # 3
print("Cols:", sheet.cols())          # 2

Limitations

  • Sheet names are stored and accessed in lowercase internally. When calling get_sheet(), always use the lowercase name (e.g., "sheet1").

API Reference

class CalcWorkbook

Represents a computed Excel workbook.

Methods

Method Description
load(filename: str) -> CalcWorkbook Loads an Excel file, computes all formulas using the formulas engine, and returns a ready-to-use workbook.
get_sheet_names() -> list[str] Returns the list of all sheet names in the workbook.
get_sheet(name: str) -> CalcSheet Returns a CalcSheet object for the given sheet name.

class CalcSheet

Represents a single computed Excel worksheet.

Methods

Method Description
rows() -> int Returns the maximum number of rows containing data.
cols() -> int Returns the maximum number of columns containing data.
cell(ref) -> Any Retrieves the computed value of a cell, either by "A1" format or [col, row] coordinates.


License

MIT License

Copyright (c) 2025 Alexandre Bento Freire

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

calc_workbook-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

calc_workbook-0.1.1-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file calc_workbook-0.1.1.tar.gz.

File metadata

  • Download URL: calc_workbook-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for calc_workbook-0.1.1.tar.gz
Algorithm Hash digest
SHA256 29d6c56c721f9e8ba02cdaea2232cae81b0c8426a9dc3ece8424f1fbd73ab2ed
MD5 65009683ace9bb38829ca4b590820427
BLAKE2b-256 33374999be61b168cfebe394684f72180a1daf096b1d7a80162568d388c5da3a

See more details on using hashes here.

File details

Details for the file calc_workbook-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: calc_workbook-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for calc_workbook-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9469de578f87b9e153113f7848e2b44049c41fc4b7a3527e3b42a3cc7a971a9
MD5 062ada1a2d536cfce5d38d4449df2f38
BLAKE2b-256 85dd8b9e2efcf66c4597d842fcbea07958025e7358d1b0caf4ffe47be88b8435

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