Skip to main content

Crate zellij_sheets

Crate zellij_sheets 

Source
Expand description

§Zellij Sheets

Terminal-native spreadsheet viewing for Zellij and the command line.

zellij-sheets is the grid and navigation layer for tabular data. It loads CSV and Excel files, renders them with a Unicode-aware layout engine, and exposes shared state and rendering logic used by both the Zellij plugin and the native CLI.

This crate is intentionally viewer-first. Workflow-level pipeline semantics, provenance, and transformation orchestration belong in nustage, not here.

§Features

  • CSV and Excel (.xlsx, .xls) loading
  • Horizontal scrolling with a real column cursor
  • Vim-style navigation primitives
  • Search state and matching helpers
  • Cell/range/write address parsing for the native CLI
  • CSV loading from stdin and CSV write-back helpers
  • Serializable spreadsheet state snapshots
  • Unicode-aware column measurement and layout

§Public Surface

  • state contains SheetsState, cursor/search behavior, and snapshot support.
  • layout contains the measurement and width-resolution engine.
  • ui contains terminal rendering helpers.
  • data_loader contains CSV/Excel loading helpers.
  • address contains cell/range/write address parsing for the native CLI.

§Usage

Read a file into shared state:

use std::path::PathBuf;
use std::sync::Arc;
use zellij_sheets::{SheetsConfig, SheetsState};

let mut state = SheetsState::new(Arc::new(SheetsConfig::default()));
state.load_file(PathBuf::from("data.csv"))?;

Parse a CLI-style cell address:

use zellij_sheets::{parse_address_command, AddressCommand, CellAddress};

let command = parse_address_command("B9")?;
assert_eq!(command, AddressCommand::Cell(CellAddress { row: 8, col: 1 }));

Example Zellij plugin config:

plugins {
    zellij-sheets location="file:/path/to/zellij-sheets.wasm"
}

Example native CLI usage:

zellij-sheets data.csv
zellij-sheets data.csv B9
zellij-sheets data.csv B1:B3
cat data.csv | zellij-sheets B2

Re-exports§

pub use address::col_letter_to_index;
pub use address::index_to_col_letters;
pub use address::parse_address_command;
pub use address::AddressCommand;
pub use address::CellAddress;
pub use config::BehaviorConfig;
pub use config::ColumnConfig;
pub use config::DisplayConfig;
pub use config::ScrollSpeed;
pub use config::SheetsConfig;
pub use config::ThemeConfig;
pub use data_loader::file_exists;
pub use data_loader::get_file_extension;
pub use data_loader::get_file_name;
pub use data_loader::get_file_size;
pub use data_loader::load_csv_from_reader;
pub use data_loader::load_data;
pub use data_loader::write_csv;
pub use state::cell_matches_query;
pub use state::DataType;
pub use state::SearchDirection;
pub use state::SheetsState;
pub use layout::fit_cell;
pub use layout::ColumnLayout;
pub use layout::LayoutCache;
pub use layout::LayoutEngine;
pub use ui::Colors;
pub use ui::UiError;
pub use ui::UiRenderer;

Modules§

address
config
data_loader
Data loading module for spreadsheet files
layout
Layout engine for zellij-sheets.
state
Core state management module for the spreadsheet viewer
ui