An open API service indexing awesome lists of open source software.

https://github.com/evans-prince/command-line-excel

A modular, command-line spreadsheet application in C featuring formula evaluation, dependency management with DAG, and efficient recalculation โ€” complete with testing, debugging, and LaTeX-based reporting.
https://github.com/evans-prince/command-line-excel

c dag dependency-graph formula-evaluator gdb latex lldb makefile memory-bugs memory-management spreadsheet valgrind vim xcode

Last synced: about 1 month ago
JSON representation

A modular, command-line spreadsheet application in C featuring formula evaluation, dependency management with DAG, and efficient recalculation โ€” complete with testing, debugging, and LaTeX-based reporting.

Awesome Lists containing this project

README

        

# Command-Line Excel: Spreadsheet Project

**Author:** Prince\
**Start Date:** 01-Feb-2025

---

## ๐Ÿ“Œ Overview

This project is a command-line spreadsheet program developed in C, supporting integer-only cell values, formulas, and efficient recalculation using a Directed Acyclic Graph (DAG). It mimics core functionalities of Excel such as cell assignment, formula evaluation, and dependency tracking, all within a terminal interface.

---

## โœจ Features

- ๐Ÿ“Š **Spreadsheet Grid**: Supports sizes from 1x1 up to 999x18278 (A1 to ZZZ999).
- ๐Ÿ”— **Formula Evaluation**: Supports arithmetic operations and range-based functions (e.g., `SUM(A1:A5)`).
- ๐Ÿ”„ **Efficient Recalculation**: Uses topological sorting and a calculation chain for updating only necessary cells.
- โ™ป๏ธ **Dependency Management**: Tracks dependencies and dependents for each cell using CellRange structs.
- โ›” **Error Handling**: Detects circular references, invalid inputs, and handles edge cases like division by zero.
- ๐Ÿงช **Testing Suite**: Modular unit tests for formula parsing, input handling, and recalculation.
- ๐Ÿงฑ **Modular Design**: Divided into reusable modules for better maintainability and scalability.

---

## ๐Ÿ› ๏ธ Design Structure

### Spreadsheet Core

- `cell** grid`: 2D array for cells.
- `calculation_chain[]`: Optimized recalculation order.
- `CommandStatus`: Stores status and execution time of last command.

### Input Handling

- Tokenizes and classifies inputs using enums.
- Validates syntax for cell assignments, formulas, function calls, and scroll commands.

### Recalculation Engine

- Dirty flag mechanism for tracking updates.
- Topological sorting to determine update order.
- Selective recalculation based on dependencies.

### Error Handling

- Invalid syntax detection.
- Circular reference prevention.
- Graceful handling of undefined operations (e.g., `A1=10/0`).

---

## ๐Ÿคฉ Directory Structure

```plaintext
.
โ”œโ”€โ”€ include/ # Header files
โ”‚ โ”œโ”€โ”€ spreadsheet.h
โ”‚ โ”œโ”€โ”€ recalculation.h
โ”‚ โ”œโ”€โ”€ input_handler.h
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ src/ # Source files
โ”‚ โ”œโ”€โ”€ spreadsheet.c
โ”‚ โ”œโ”€โ”€ recalculation.c
โ”‚ โ”œโ”€โ”€ input_handler.c
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ lib/ # Utility functions
โ”‚ โ””โ”€โ”€ utils.c
โ”œโ”€โ”€ tests/ # Unit tests
โ”‚ โ”œโ”€โ”€ test_input.c
โ”‚ โ”œโ”€โ”€ test_formula.c
โ”‚ โ””โ”€โ”€ ...
โ”œโ”€โ”€ Makefile # Build automation
โ””โ”€โ”€ report/ # LaTeX report files
โ””โ”€โ”€ report.pdf
```

---

## How to Run ๐Ÿš€

### Prerequisites

A Linux, macOS, or Windows system with:
- GCC (GNU Compiler Collection)
- `make` or `mingw32-make`
- `pdflatex` for LaTeX report generation (optional)

### ๐Ÿ”ข Build & Run Commands

#### Linux/macOS:
```bash
# Clone the repository
git clone https://github.com/evans-prince/Command-Line-Excel.git
cd Command-Line-Excel/Command-Line-Excel

# Build the project
make

# Run the program
./target/release/spreadsheet 999 18278
```

#### Windows:
```bash
# Open Command Prompt (cmd) or Git Bash

# Clone the repository
git clone https://github.com/evans-prince/Command-Line-Excel.git
cd Command-Line-Excel\Command-Line-Excel

# Build the project
mingw32-make

# Run the program
.target/release/spreadsheet.exe 999 18278
```

### ๐Ÿ“‰ Optional Commands
```bash
# Run provided tests (Linux/macOS)
make test

# Run tests on Windows
mingw32-make test

# Clean build files
make clean # Linux/macOS
mingw32-make clean # Windows
```

---

## ๐Ÿ”— Project Links

- ๐Ÿ“ **GitHub Repository**: [Command-Line Excel](https://github.com/evans-prince/Command-Line-Excel)
- ๐Ÿ“ฝ๏ธ **Demo Video**: [Watch Demo](https://csciitd-my.sharepoint.com/:v:/g/personal/ph1221248_iitd_ac_in/EYGqIFa5qNRIl2LBnGHC8h8BVRATkNtxBRx4TYOI_3kHiQ?e=2s2BGr)

---

## ๐Ÿ“ฃ Contributions

This project was collaboratively developed by:

- ๐Ÿ‘จโ€๐Ÿ’ป Prince
- ๐Ÿ‘จโ€๐Ÿ’ป Aditya

---

## ๐Ÿ“ž Contact

If you'd like to know more or contribute, feel free to open an issue or contact us via GitHub!