Skip to content

akryptonian/Spreadsheet-Engine

Repository files navigation

Spreadsheet-Engine

A CLI-based spreadsheet engine written in C.

Spreadsheet-Engine brings spreadsheet-like arithmetic and functions to the command line. You interact with the grid by entering formulas directly and navigating with simple key commands—no traditional spreadsheet GUI, but a true terminal experience!

Features

  • Direct formula entry: Assign cell values and formulas with statements like A1=5, B2=A1+10, or C3=SUM(A1:B2).
  • Cell referencing: Use cell names (e.g., A1, B2, AA10) in formulas, with multi-letter columns supported.
  • Basic math: Supports +, -, *, /, parentheses, and negative numbers.
  • Functions: SUM, MIN, MAX, AVG, STDEV, SLEEP (for timing).
  • Viewport navigation: Move through the spreadsheet using w (up), a (left), s (down), and d (right) keys.
  • Instant feedback: Spreadsheet is printed automatically after every command.
  • Robust error handling: Catches invalid formulas, cell references, and division by zero.
  • Fast, minimal implementation: Built in portable C for educational and scripting use.

Getting Started

Build

Requires a C99-compatible compiler and make.

git clone https://github.com/akryptonian/Spreadsheet-Engine.git
cd Spreadsheet-Engine
make

Executable will be built in ./target/release/spreadsheet.

Run

./target/release/spreadsheet <rows> <cols>

For example:

./target/release/spreadsheet 20 20

Usage

  • Assign a value/formula:
    Type A1=10 or B2=A1*2+5 and press Enter.
  • Use functions:
    Type C1=SUM(A1:B2) or D1=AVG(A1:B2).
  • Navigate the viewport:
    Use keys:
    • w — scroll up
    • a — scroll left
    • s — scroll down
    • d — scroll right
  • Disable output:
    Type disable_output to stop printing the spreadsheet on each command.
    Type enable_output to resume printing.
  • Quit:
    Type q and press Enter.

Note: There are no commands like GET, SET, PRINT, SAVE, or LOAD. All interactions are through formulas and simple navigation shortcuts.

Example Session

A1=5
B1=3
C1=A1+B1*2
D1=SUM(A1:C1)
w    # move viewport up
s    # move viewport down
q    # exit

After each formula or navigation command, the spreadsheet grid is automatically printed (unless disabled).

Internals

  • Core functions: set_cell, get_cell, print_spreadsheet, parse_formula, evaluate_expression, evaluate_range
  • Error handling: Invalid formulas, cell references, and arithmetic errors are caught and reported.
  • Data structure: Dynamically allocated 2D grid of cells, with support for multi-letter columns.

Future Improvements

  • Persistent saving/loading of spreadsheet data (currently not implemented)
  • More advanced functions
  • GUI or TUI enhancements

License

MIT License. See LICENSE for details.


Made by akryptonian

About

A CLI based Spreadsheet Engine written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published