wip: Use ironcalc

This commit is contained in:
Jeremy Wall 2024-11-11 19:27:59 -05:00
parent 694840077d
commit dcaee6993b
6 changed files with 890 additions and 6 deletions

865
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ anyhow = { version = "1.0.91", features = ["backtrace"] }
clap = { version = "4.5.20", features = ["derive"] }
crossterm = { version = "0.28.1", features = ["event-stream"] }
csvx = "0.1.17"
ironcalc = { git = "https://github.com/ironcalc/IronCalc" }
futures = "0.3.31"
ratatui = "0.29.0"
thiserror = "1.0.65"

28
src/book/mod.rs Normal file
View File

@ -0,0 +1,28 @@
use anyhow::{anyhow, Result};
use ironcalc::base::{Model, types::{Worksheet, SheetData}};
pub struct Book {
model: Model,
current_sheet: u32,
current_location: (u32, u32),
}
impl Book {
pub fn get_sheet_name(&self) -> Result<&str> {
Ok(&self.get_sheet()?.name)
}
pub fn get_sheet_data(&self) -> Result<&SheetData> {
Ok(&self.get_sheet()?.sheet_data)
}
fn get_sheet(&self) -> Result<&Worksheet> {
Ok(self.model.workbook.worksheet(self.current_sheet)
.map_err(|s| anyhow!("Invalid Worksheet: {}", s))?)
}
fn get_sheet_mut(&mut self) -> Result<&mut Worksheet> {
Ok(self.model.workbook.worksheet_mut(self.current_sheet)
.map_err(|s| anyhow!("Invalid Worksheet: {}", s))?)
}
}

View File

@ -6,6 +6,7 @@ use ui::Workspace;
mod sheet;
mod ui;
mod book;
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]

View File

View File

@ -8,6 +8,7 @@
use anyhow::{anyhow, Result};
use csvx;
use ironcalc::base::{Workbook, Table};
use std::borrow::Borrow;