mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-22 13:00:22 -04:00
wip: Use ironcalc
This commit is contained in:
parent
694840077d
commit
dcaee6993b
865
Cargo.lock
generated
865
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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
28
src/book/mod.rs
Normal 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))?)
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ use ui::Workspace;
|
||||
|
||||
mod sheet;
|
||||
mod ui;
|
||||
mod book;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
|
@ -8,6 +8,7 @@
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use csvx;
|
||||
use ironcalc::base::{Workbook, Table};
|
||||
|
||||
use std::borrow::Borrow;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user