pub struct WorkbookSession { /* private fields */ }Expand description
Surface-agnostic in-memory workbook session.
This API avoids workbook IDs, fork handles, and MCP-specific wiring so it can be reused by CLI, SDK, or WASM bindings.
Implementations§
Source§impl WorkbookSession
impl WorkbookSession
Sourcepub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self>
pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result<Self>
Open a workbook session from raw XLSX bytes.
Sourcepub fn from_path(path: impl AsRef<Path>) -> Result<Self>
pub fn from_path(path: impl AsRef<Path>) -> Result<Self>
Open a workbook session from a filesystem path.
Sourcepub fn list_sheets(&self) -> Vec<String>
pub fn list_sheets(&self) -> Vec<String>
Return sheet names in workbook order.
Sourcepub fn describe_workbook(&self) -> Result<WorkbookDescription>
pub fn describe_workbook(&self) -> Result<WorkbookDescription>
Return workbook-level descriptor for this in-memory session.
Sourcepub fn named_ranges(&self) -> Result<NamedRangesResponse>
pub fn named_ranges(&self) -> Result<NamedRangesResponse>
Return workbook defined names and table descriptors.
Sourcepub fn define_name(
&mut self,
name: &str,
refers_to: &str,
scope: Option<&str>,
scope_sheet_name: Option<&str>,
) -> Result<DefineNameResponse>
pub fn define_name( &mut self, name: &str, refers_to: &str, scope: Option<&str>, scope_sheet_name: Option<&str>, ) -> Result<DefineNameResponse>
Define a new named range.
Sourcepub fn update_name(
&mut self,
name: &str,
refers_to: Option<&str>,
scope: Option<&str>,
scope_sheet_name: Option<&str>,
) -> Result<UpdateNameResponse>
pub fn update_name( &mut self, name: &str, refers_to: Option<&str>, scope: Option<&str>, scope_sheet_name: Option<&str>, ) -> Result<UpdateNameResponse>
Update an existing named range.
Sourcepub fn delete_name(
&mut self,
name: &str,
scope: Option<&str>,
scope_sheet_name: Option<&str>,
) -> Result<DeleteNameResponse>
pub fn delete_name( &mut self, name: &str, scope: Option<&str>, scope_sheet_name: Option<&str>, ) -> Result<DeleteNameResponse>
Delete a named range.
Sourcepub fn sheet_overview(
&self,
params: SessionSheetOverviewParams,
) -> Result<SheetOverviewResponse>
pub fn sheet_overview( &self, params: SessionSheetOverviewParams, ) -> Result<SheetOverviewResponse>
Return overview/classification information for a sheet.
Sourcepub fn find_value(
&self,
params: SessionFindValueParams,
) -> Result<FindValueResponse>
pub fn find_value( &self, params: SessionFindValueParams, ) -> Result<FindValueResponse>
Search for values in one sheet or across all sheets.
Sourcepub fn read_table(
&self,
params: SessionReadTableParams,
) -> Result<ReadTableResponse>
pub fn read_table( &self, params: SessionReadTableParams, ) -> Result<ReadTableResponse>
Read a rectangular table snapshot from a sheet.
Sourcepub fn range_values(
&self,
sheet_name: &str,
ranges: impl Into<SessionRangeSelection>,
) -> Result<Vec<RangeValuesEntry>>
pub fn range_values( &self, sheet_name: &str, ranges: impl Into<SessionRangeSelection>, ) -> Result<Vec<RangeValuesEntry>>
Read one or more A1 ranges from a sheet.
Sourcepub fn sheet_page(
&self,
params: SessionSheetPageParams,
) -> Result<SheetPageResponse>
pub fn sheet_page( &self, params: SessionSheetPageParams, ) -> Result<SheetPageResponse>
Read a page-oriented snapshot from a sheet.
Sourcepub fn grid_export(&self, sheet_name: &str, range: &str) -> Result<GridPayload>
pub fn grid_export(&self, sheet_name: &str, range: &str) -> Result<GridPayload>
Export a range as grid payload (value/formula/style patch surface).
Sourcepub fn apply_ops(
&mut self,
ops: &[SessionTransformOp],
) -> Result<SessionApplySummary>
pub fn apply_ops( &mut self, ops: &[SessionTransformOp], ) -> Result<SessionApplySummary>
Apply a transform batch in-session.
For this extraction pass we support write_matrix operations.
Sourcepub fn apply_write_matrix(
&mut self,
sheet_name: impl Into<String>,
anchor: impl Into<String>,
rows: Vec<Vec<Option<SessionMatrixCell>>>,
overwrite_formulas: bool,
) -> Result<SessionApplySummary>
pub fn apply_write_matrix( &mut self, sheet_name: impl Into<String>, anchor: impl Into<String>, rows: Vec<Vec<Option<SessionMatrixCell>>>, overwrite_formulas: bool, ) -> Result<SessionApplySummary>
Convenience wrapper for a single write_matrix operation.
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>>
pub fn to_bytes(&self) -> Result<Vec<u8>>
Serialize the current in-memory workbook state back to XLSX bytes.
Sourcepub fn to_temp_file(&self) -> Result<NamedTempFile>
pub fn to_temp_file(&self) -> Result<NamedTempFile>
Write current workbook state to a temporary XLSX file.
The caller owns the NamedTempFile and must keep it alive for as long as
the path is needed (e.g. during apply-to-file round-trips).
Sourcepub fn reload_from_path(&mut self, path: &Path) -> Result<()>
pub fn reload_from_path(&mut self, path: &Path) -> Result<()>
Reload in-memory workbook state from an on-disk XLSX file.
Used after an external apply_*_to_file() function has mutated the file
to bring the session back in sync.
Sourcepub fn into_bytes(self) -> Result<Vec<u8>>
pub fn into_bytes(self) -> Result<Vec<u8>>
Serialize and consume the current in-memory workbook state.
Sourcepub fn sheet_by_name(&self, sheet_name: &str) -> Option<&Worksheet>
pub fn sheet_by_name(&self, sheet_name: &str) -> Option<&Worksheet>
Look up a sheet by name, returning Some if found.
Auto Trait Implementations§
impl Freeze for WorkbookSession
impl RefUnwindSafe for WorkbookSession
impl Send for WorkbookSession
impl Sync for WorkbookSession
impl Unpin for WorkbookSession
impl UnsafeUnpin for WorkbookSession
impl UnwindSafe for WorkbookSession
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more