Skip to content

a-bentofreire/calc-workbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

calc-workbook is a lightweight Python package that loads Excel files, computes all formulas using the formulas

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages