A high-performance spreadsheet implementation in Rust, focusing on memory efficiency and processing speed.
Ferro Spreadsheet is a command-line spreadsheet application that supports:
- Basic arithmetic operations
- Cell references and formulas
- Range-based functions (SUM, AVG, MIN, MAX, STDEV)
- Special operations like SLEEP()
- Efficient handling of large spreadsheets
- Dependency tracking and cycle detection
Our project includes comprehensive rustdoc documentation that can be accessed in two ways:
You can generate and view the documentation locally by running:
# Generate documentation
cargo doc --no-deps --open
This will build the documentation and open it in your default web browser.
Our rustdoc comments follow these principles:
- Module-level documentation: Each module (.rs file) includes a detailed overview explaining its purpose, main components, and usage patterns
- Struct and trait documentation: All public structs and traits have documentation explaining their purpose and usage
- Method documentation: Public methods include:
- Brief description of functionality
- Parameter explanations
- Return value descriptions
- Example usage where appropriate
- Notes on edge cases and error handling
Here's an example of our rustdoc style:
/// Represents a cell value in the spreadsheet.
///
/// Cell values can either be integers or error values.
/// This enum is used throughout the spreadsheet for storing
/// and manipulating cell contents.
#[derive(Debug, Clone, PartialEq)]
pub enum CellValue {
/// An integer value stored in a cell
Integer(i32),
/// Represents an error in the cell (e.g., division by zero)
Error,
}
The project uses rustdoc for comprehensive code documentation. Here's how to build and access it:
# Generate documentation without external dependencies
cargo doc --no-deps
After generating the documentation, you can access it in several ways depending on your environment:
# Generate and automatically open documentation in browser
cargo doc --no-deps --open
If you're using WSL and encounter the "couldn't open docs" error, you can:
-
Generate the docs without the open flag:
cargo doc --no-deps
-
Then manually open the HTML file using your Windows browser:
# Option 1: Using the Windows path explorer.exe $(wslpath -w ./target/doc/spreadsheet/index.html) # Option 2: Copy the path and open manually echo "$(wslpath -w $(pwd))/target/doc/spreadsheet/index.html" # Then copy the output path and paste in your browser
# Make sure you have xdg-open installed
sudo apt install xdg-utils # For Debian/Ubuntu
# Then run
cargo doc --no-deps --open
You can also configure rustdoc to include additional features:
# Generate documentation with all features enabled
cargo doc --all-features --no-deps --open
# Generate private items documentation (including internal functions)
cargo doc --document-private-items --no-deps --open
The documentation is generated in HTML format and stored in the target/doc
directory. The index page provides an overview of all modules and types.
- Rust and Cargo (install from https://rustup.rs/)
# Clone the repository
git clone https://github.com/username/ferro_spreadsheet.git
cd ferro_spreadsheet
# Build the project
cargo build --release
# Run with desired dimensions (rows columns)
cargo run --release -- 999 18278
A1=42
- Set cell A1 to the value 42B1=A1+10
- Set B1 to A1's value plus 10C1=SUM(A1:B5)
- Set C1 to the sum of the range A1:B5w
,a
,s
,d
- Scroll viewportscroll_to A10
- Move viewport to cell A10enable_output
,disable_output
- Toggle spreadsheet displayq
- Quit the application
h
to move left,j
to move down ,k
to move up ,l
to move the cursor rightvisual A1
- Show dependencies for cell A1i
to enter insert modeesc
to exit insert mode:q
to quit the program:wq
to save and quit the program:w
to save the programHLP (cell)
to highlight parentHLC (cell)
to highlight childrenHLPC (cell)
to highlight parent and childrenHV (Range) Standard function
AVG,SUM,MAX,STDEV,MIN to get the range value using the function- Pressing upper arrow goes to previous command
- Pressing down arrow goes to more recent command
history <cell>
to revert back to previous value of the celllock_cell <cell/range>
to disable editing value of the cell or range of cellslast_edit
makes the last edited cell the top left cellname <cell/range> <name>
to name a cell or range of cells and use the name laterunlock_cell <cell>
to enable editing the value of disabled cellis_locked <cell>
to check if the cell is locked
Our testing strategy includes:
- Unit Tests - Testing individual components in isolation
- Integration Tests - Testing interactions between components
- Continuous Integration - Automated testing on GitHub Actions
Current test coverage is over 80%, validating our code's correctness and reliability.
Our design provides several advantages:
- Memory Efficiency: By using sparse data structures, we avoid allocating memory for empty cells
- Performance: Topological sorting and efficient data structures minimize recalculation time
- Maintainability: Clear separation of concerns makes the code easy to understand and extend
- Flexibility: The design allows for easy addition of new formula types and functions
- Safety: Rust's ownership model helps prevent memory leaks and data races
This design balances memory usage, performance, and code clarity, making it suitable for both small and large spreadsheets.