Skip to main content

File

Struct File 

Source
pub struct File {
Show 27 fields pub path: Mutex<String>, pub options: Mutex<Options>, pub sheet_count: Mutex<i32>, pub pkg: DashMap<String, Vec<u8>>, pub sheet: DashMap<String, XlsxWorksheet>, pub relationships: DashMap<String, XlsxRelationships>, pub temp_files: DashMap<String, String>, pub sheet_map: Mutex<HashMap<String, String>>, pub xml_attr: DashMap<String, String>, pub checked: DashMap<String, bool>, pub zip64_entries: Mutex<Vec<String>>, pub content_types: Mutex<Option<XlsxTypes>>, pub styles: Mutex<Option<XlsxStyleSheet>>, pub workbook: Mutex<Option<XlsxWorkbook>>, pub calc_chain: Mutex<Option<XlsxCalcChain>>, pub volatile_deps: Mutex<Option<XlsxVolTypes>>, pub calc_cache: Mutex<HashMap<String, String>>, pub calc_raw_cache: Mutex<HashMap<String, String>>, pub formula_arg_cache: Mutex<HashMap<String, FormulaArg>>, pub theme: Mutex<Option<DecodeTheme>>, pub shared_strings: Mutex<Option<XlsxSst>>, pub shared_strings_map: Mutex<HashMap<String, i32>>, pub drawings: DashMap<String, XlsxWsDr>, pub comments: DashMap<String, XlsxComments>, pub vml_drawing: DashMap<String, VmlDrawing>, pub charset_transcoder: Mutex<Option<CharsetTranscoderFn>>, pub zip_writer_factory: Mutex<Option<ZipWriterFactory>>, /* private fields */
}
Expand description

Populated spreadsheet file.

Fields§

§path: Mutex<String>

Path used by Save.

§options: Mutex<Options>

User-provided options.

§sheet_count: Mutex<i32>

Number of worksheets in the workbook.

§pkg: DashMap<String, Vec<u8>>

In-memory package parts (path → raw bytes).

§sheet: DashMap<String, XlsxWorksheet>

Parsed worksheets (path → worksheet).

§relationships: DashMap<String, XlsxRelationships>

Parsed relationship parts (path → relationships).

§temp_files: DashMap<String, String>

Temporary file mapping (path → filesystem path).

§sheet_map: Mutex<HashMap<String, String>>

Map of worksheet names to XML paths.

§xml_attr: DashMap<String, String>

Captured root namespace attributes for each XML part.

§checked: DashMap<String, bool>

Marks worksheets that have already been validated.

§zip64_entries: Mutex<Vec<String>>

Entries that exceed 4GB and need a ZIP64 LFH patch.

§content_types: Mutex<Option<XlsxTypes>>

Lazily loaded [Content_Types].xml.

§styles: Mutex<Option<XlsxStyleSheet>>

Lazily loaded xl/styles.xml.

§workbook: Mutex<Option<XlsxWorkbook>>

Lazily loaded xl/workbook.xml.

§calc_chain: Mutex<Option<XlsxCalcChain>>

Lazily loaded xl/calcChain.xml.

§volatile_deps: Mutex<Option<XlsxVolTypes>>

Lazily loaded xl/volatileDependencies.xml.

§calc_cache: Mutex<HashMap<String, String>>

Cached calculated cell values (formatted).

§calc_raw_cache: Mutex<HashMap<String, String>>

Cached calculated cell values (raw).

§formula_arg_cache: Mutex<HashMap<String, FormulaArg>>

Cached formula argument values for dependent cell reuse.

§theme: Mutex<Option<DecodeTheme>>

Lazily loaded theme part.

§shared_strings: Mutex<Option<XlsxSst>>

Lazily loaded shared string table.

§shared_strings_map: Mutex<HashMap<String, i32>>

Index map for shared strings.

§drawings: DashMap<String, XlsxWsDr>

Parsed worksheet drawings (path → drawing).

§comments: DashMap<String, XlsxComments>

Parsed comments parts (path → comments).

§vml_drawing: DashMap<String, VmlDrawing>

Parsed VML drawings (path → VML drawing).

§charset_transcoder: Mutex<Option<CharsetTranscoderFn>>

Optional codepage transcoder for non-UTF-8 XML package parts.

§zip_writer_factory: Mutex<Option<ZipWriterFactory>>

Optional ZIP writer factory used when saving the workbook.

Implementations§

Source§

impl File

Source

pub fn calc_cell_value(&self, sheet: &str, cell: &str) -> Result<String>

Calculate the value of a single cell. If the cell contains a formula, the formula is parsed and evaluated; otherwise the cached/raw value is returned. Uses the Options stored on the workbook.

Source

pub fn calc_cell_value_with_options( &self, sheet: &str, cell: &str, opts: &Options, ) -> Result<String>

Calculate the value of a single cell with an explicit set of options.

Source§

impl File

Source

pub fn calc_chain_reader(&self) -> Result<XlsxCalcChain>

Lazy reader for xl/calcChain.xml.

Source

pub fn calc_chain_writer(&self)

Serialize and save xl/calcChain.xml if it contains entries.

Source

pub fn delete_calc_chain(&self, index: i32, cell: &str) -> Result<()>

Remove a cell reference from the calculation chain.

Source

pub fn volatile_deps_reader(&self) -> Result<Option<XlsxVolTypes>>

Lazy reader for xl/volatileDependencies.xml.

Source

pub fn volatile_deps_writer(&self)

Serialize and save xl/volatileDependencies.xml.

Source§

impl File

Source

pub fn set_cell_value( &self, sheet: &str, cell: &str, value: impl Into<CellValue>, ) -> Result<()>

Set the value of a cell.

Source

pub fn get_cell_value(&self, sheet: &str, cell: &str) -> Result<String>

Get the raw string value of a cell.

Source

pub fn get_cell_value_with_options( &self, sheet: &str, cell: &str, raw: bool, ) -> Result<String>

Get the formatted value of a cell, optionally bypassing number formatting.

Source

pub fn get_cell_type(&self, sheet: &str, cell: &str) -> Result<CellType>

Get the data type of a cell.

Source

pub fn set_cell_str(&self, sheet: &str, cell: &str, value: &str) -> Result<()>

Set a cell to a string value.

Source

pub fn set_cell_int(&self, sheet: &str, cell: &str, value: i64) -> Result<()>

Set a cell to an integer value.

Source

pub fn set_cell_uint(&self, sheet: &str, cell: &str, value: u64) -> Result<()>

Set a cell to an unsigned integer value.

Source

pub fn set_cell_float(&self, sheet: &str, cell: &str, value: f64) -> Result<()>

Set a cell to a floating point value.

Source

pub fn set_cell_float_with_precision( &self, sheet: &str, cell: &str, value: f64, precision: i32, bit_size: i32, ) -> Result<()>

Set a cell to a floating point value with explicit precision and bit size.

precision of -1 uses as many decimal places as necessary. bit_size should be 32 for f32 values and 64 for f64 values.

Source

pub fn set_cell_bool(&self, sheet: &str, cell: &str, value: bool) -> Result<()>

Set a cell to a boolean value.

Source

pub fn set_cell_default( &self, sheet: &str, cell: &str, value: &str, ) -> Result<()>

Set a cell to a string value without escaping it as a shared string.

Source

pub fn set_cell_formula( &self, sheet: &str, cell: &str, formula: &str, ) -> Result<()>

Set a cell formula.

Source

pub fn set_cell_formula_with_opts( &self, sheet: &str, cell: &str, formula: &str, opts: &[FormulaOpts], ) -> Result<()>

Set a cell formula with optional formula type and reference range.

Source

pub fn get_cell_formula(&self, sheet: &str, cell: &str) -> Result<String>

Get the formula from a cell.

Source

pub fn get_cell_style(&self, sheet: &str, cell: &str) -> Result<i32>

Get the style index applied to a cell.

If the cell has no explicit style, the row style and then the column style are returned, matching Excel’s inheritance behavior.

Source

pub fn set_cell_style( &self, sheet: &str, top_left_cell: &str, bottom_right_cell: &str, style_id: i32, ) -> Result<()>

Apply a style index to a range of cells.

The range is defined by top_left_cell and bottom_right_cell. The corners are normalized automatically, so B3:A1 is equivalent to A1:B3. Passing the same cell for both corners styles a single cell.

Source

pub fn set_cell_rich_text( &self, sheet: &str, cell: &str, runs: Vec<RichTextRun>, ) -> Result<()>

Set rich text runs to a cell.

Source

pub fn get_cell_rich_text( &self, sheet: &str, cell: &str, ) -> Result<Vec<RichTextRun>>

Get rich text runs from a cell.

Get a cell hyperlink.

Returns (true, link) if the cell has a hyperlink, otherwise (false, "").

Get all cell references which contain hyperlinks in a worksheet.

link_type may be "External", "Location", "None" or empty.

Set a cell hyperlink.

Source

pub fn set_sheet_row( &self, sheet: &str, cell: &str, values: &[CellValue], ) -> Result<()>

Write a row of values starting at the given cell.

Source

pub fn set_sheet_col( &self, sheet: &str, cell: &str, values: &[CellValue], ) -> Result<()>

Write a column of values starting at the given cell.

Source§

impl File

Source

pub fn add_chart( &mut self, sheet: &str, cell: &str, chart: &Chart, ) -> Result<()>

Add a chart to a worksheet.

Source

pub fn add_chart_sheet(&mut self, sheet: &str, chart: &Chart) -> Result<()>

Create a chartsheet (a worksheet containing only a chart).

Source

pub fn delete_chart(&mut self, sheet: &str, cell: &str) -> Result<()>

Delete the chart at a given cell in a worksheet.

Source

pub fn get_charts(&self, sheet: &str) -> Result<Vec<Chart>>

Return all charts embedded in a worksheet.

Source§

impl File

Source

pub fn set_col_width( &self, sheet: &str, start_col: &str, end_col: &str, width: f64, ) -> Result<()>

Set the width of one or more columns.

Source

pub fn get_col_width(&self, sheet: &str, col: &str) -> Result<f64>

Get the width of a column.

Source

pub fn set_col_visible( &self, sheet: &str, start_col: &str, end_col: &str, visible: bool, ) -> Result<()>

Set the visibility of one or more columns.

Source

pub fn get_col_visible(&self, sheet: &str, col: &str) -> Result<bool>

Get the visibility of a column.

Source

pub fn set_col_outline_level( &self, sheet: &str, start_col: &str, end_col: &str, level: u8, ) -> Result<()>

Set the outline level of one or more columns.

Source

pub fn get_col_outline_level(&self, sheet: &str, col: &str) -> Result<u8>

Get the outline level of a column.

Source

pub fn insert_cols(&self, sheet: &str, col: &str, n: usize) -> Result<()>

Insert n columns before col.

Source

pub fn remove_col(&self, sheet: &str, col: &str) -> Result<()>

Remove a column.

Source

pub fn set_col_style( &self, sheet: &str, start_col: &str, end_col: &str, style_id: i32, ) -> Result<()>

Apply a style index to one or more columns.

Source

pub fn get_col_style(&self, sheet: &str, col: &str) -> Result<i32>

Get the style ID applied to a column.

Source

pub fn auto_fit_col_width(&self, sheet: &str, columns: &str) -> Result<()>

Auto fit column width according to the text content.

Equivalent to Go AutoFitColWidth. The width is calculated approximately based on the default font format.

Source§

impl File

Source

pub fn cols(&self, sheet: &str) -> Result<Cols<'_>>

Return a streaming iterator over the columns of a worksheet.

Source

pub fn get_cols(&self, sheet: &str, opts: Options) -> Result<Vec<Vec<String>>>

Return all columns in a worksheet as a two-dimensional vector of strings.

Source§

impl File

Source

pub fn add_data_validation( &self, sheet: &str, dv: &DataValidation, ) -> Result<()>

Add a data validation rule to a worksheet.

Source

pub fn get_data_validations(&self, sheet: &str) -> Result<Vec<DataValidation>>

Get the data validation rules for a worksheet.

Source

pub fn delete_data_validation(&self, sheet: &str, sqref: &[&str]) -> Result<()>

Delete data validation rules from a worksheet.

Source§

impl File

Source

pub fn set_app_props(&mut self, props: &AppProperties) -> Result<()>

Set the document application properties (docProps/app.xml).

Source

pub fn get_app_props(&self) -> Result<AppProperties>

Get the document application properties.

Source

pub fn set_doc_props(&mut self, props: &DocProperties) -> Result<()>

Set the document core properties (docProps/core.xml).

Source

pub fn get_doc_props(&self) -> Result<DocProperties>

Get the document core properties.

Source

pub fn set_custom_props(&mut self, prop: &CustomProperty) -> Result<()>

Set a custom document property by name and value. A property with a None value is deleted.

Source

pub fn get_custom_props(&self) -> Result<Vec<CustomProperty>>

Get all custom document properties.

Source

pub fn delete_custom_props(&mut self, name: &str) -> Result<()>

Delete a custom document property by name.

Source§

impl File

Source

pub fn new() -> Self

Create a new blank workbook.

Source

pub fn new_with_options(opts: Options) -> Self

Create a new blank workbook with options.

Source

pub fn open_file(path: &str, opts: Options) -> Result<Self>

Open a workbook from the filesystem.

Source

pub fn open_reader<R: Read + Seek>( reader: R, _size: u64, opts: Options, ) -> Result<Self>

Open a workbook from a readable/seekable source.

Source

pub fn save(&self) -> Result<()>

Save to the original path.

Source

pub fn save_as(&mut self, path: &str) -> Result<()>

Save the workbook to the given path.

Source

pub fn write_to<W: Write>(&self, writer: W) -> Result<()>

Write the workbook to any writer.

Source

pub fn close(&mut self) -> Result<()>

Clean up temporary files.

Source

pub fn charset_transcoder<F>(&self, transcoder: F) -> &Self
where F: Fn(&str, Box<dyn Read>) -> Result<Box<dyn Read>> + Send + Sync + 'static,

Set a user-defined charset transcoder for non-UTF-8 XML package parts.

Mirrors Go File.CharsetTranscoder.

Source

pub fn set_zip_writer<F>(&self, factory: F) -> &Self
where F: for<'a> Fn(&'a mut dyn WriteSeek) -> Box<dyn ZipWriter + 'a> + Send + Sync + 'static,

Set a user-defined ZIP writer factory for saving the workbook.

Mirrors Go File.SetZipWriter. The factory receives a writer that also implements Seek because the underlying zip::ZipWriter needs to seek back to write the central directory.

Source

pub fn read_xml(&self, name: &str) -> Vec<u8>

Read XML content as bytes from the in-memory package.

Source

pub fn read_bytes(&self, name: &str) -> Vec<u8>

Read file content as bytes, falling back to temporary files.

Source

pub fn save_file_list(&self, name: &str, content: &[u8])

Update or add a package part, prefixing the standard XML header.

Source

pub fn content_types_reader(&self) -> Result<XlsxTypes>

Lazy reader for [Content_Types].xml.

Source

pub fn styles_reader(&self) -> Result<XlsxStyleSheet>

Lazy reader for xl/styles.xml.

Source

pub fn workbook_reader(&self) -> Result<XlsxWorkbook>

Lazy reader for xl/workbook.xml.

Source

pub fn theme_reader(&self) -> Result<Option<DecodeTheme>>

Lazy reader for the theme part.

Source

pub fn shared_strings_reader(&self) -> Result<XlsxSst>

Lazy reader for the shared string table.

Source

pub fn rels_reader(&self, path: &str) -> Result<Option<XlsxRelationships>>

Lazy reader for relationship parts.

Source

pub fn metadata_reader(&self) -> Result<XlsxMetadata>

Lazy reader for xl/metadata.xml.

Source

pub fn rich_value_reader(&self) -> Result<XlsxRichValueData>

Lazy reader for xl/richData/rdrichvalue.xml.

Source

pub fn rich_value_rel_reader(&self) -> Result<XlsxRichValueRels>

Lazy reader for xl/richData/richValueRel.xml.

Source

pub fn rich_value_structures_reader(&self) -> Result<XlsxRichValueStructures>

Lazy reader for xl/richData/rdrichvaluestructure.xml.

Source

pub fn rich_value_web_image_reader( &self, ) -> Result<XlsxWebImagesSupportingRichData>

Lazy reader for xl/richData/rdRichValueWebImage.xml.

Source

pub fn set_rels( &self, r_id: &str, rel_path: &str, rel_type: &str, target: &str, target_mode: &str, ) -> i32

Set an existing relationship entry, or add a new one if r_id is empty.

Source

pub fn add_rels( &self, rel_path: &str, rel_type: &str, target: &str, target_mode: &str, ) -> i32

Add a relationship to a relationship part.

Source

pub fn get_workbook_path(&self) -> String

Get the workbook XML path from the root relationships.

Source

pub fn get_workbook_rels_path(&self) -> String

Get the workbook relationships path.

Source

pub fn get_worksheet_path(&self, rel_target: &str) -> String

Convert a relative relationship target to an absolute package path.

Source

pub fn get_sheet_xml_path(&self, sheet: &str) -> Option<String>

Get the XML path for a worksheet by name.

Source

pub fn work_sheet_reader(&self, sheet: &str) -> Result<XlsxWorksheet>

Deserialize and return a worksheet by name.

Source

pub fn write_to_buffer(&self) -> Result<Vec<u8>>

Serialize the workbook to an in-memory byte buffer.

Source

pub fn add_name_spaces(&self, path: &str, ns: &str)

Register a namespace attribute for the given XML part so that it is written back when the part is serialized.

ns is the namespace URI; the prefix is looked up from the project’s namespace dictionary. For known extension namespaces the mc:Ignorable attribute is also updated so Excel compatibility markup stays valid.

Source

pub fn get_sheet_id(&self, sheet: &str) -> i32

Return the sheet ID (1-based) for a worksheet name.

Source

pub fn expand_3d_sheet_range( &self, sheet1: &str, sheet2: &str, ) -> Result<Vec<String>>

Expand a 3D sheet range (e.g. Sheet1:Sheet3) into the ordered list of worksheet names between the two sheets inclusive.

Source

pub fn clear_calc_cache(&self)

Clear the in-memory calc cache so the chain is rewritten on save.

Source

pub fn add_content_type_part(&self, id: i32, part: &str) -> Result<()>

Add a content type override for a numbered part.

Source

pub fn remove_content_types_part( &self, content_type: &str, part_name: &str, ) -> Result<()>

Remove a content type override by content type and part name prefix.

Source

pub fn get_sheet_relationships_target_by_id( &self, sheet: &str, r_id: &str, ) -> String

Return the relationship target for a worksheet relationship by rId.

Source

pub fn add_sheet_legacy_drawing(&self, sheet: &str, r_id: i32) -> Result<()>

Add a legacy drawing reference to a worksheet.

Source

pub fn add_sheet_legacy_drawing_hf(&self, sheet: &str, r_id: i32) -> Result<()>

Add a legacy header/footer drawing reference to a worksheet.

Source

pub fn count_comments(&self) -> i32

Count existing comments parts in the package.

Source

pub fn count_vml_drawing(&self) -> i32

Count existing VML drawing parts in the package.

Source

pub fn comments_reader(&self, path: &str) -> Result<Option<XlsxComments>>

Lazy reader for comments parts.

Source

pub fn vml_drawing_reader(&self, path: &str) -> Result<Option<VmlDrawing>>

Lazy reader for VML drawing parts.

Source

pub fn delete_sheet_relationships(&self, sheet: &str, r_id: &str)

Delete a worksheet relationship by rId.

Source

pub fn delete_workbook_rels( &self, rel_type: &str, target: &str, ) -> Result<String>

Delete a workbook relationship by type and target, returning its rId.

Source

pub fn add_sheet_drawing(&self, sheet: &str, r_id: i32) -> Result<()>

Add a drawing relationship reference to a worksheet.

Source

pub fn count_tables(&self) -> i32

Count existing table parts in the package.

Source

pub fn count_drawings(&self) -> i32

Count existing drawing parts in the package.

Source

pub fn count_charts(&self) -> i32

Count existing chart parts in the package.

Source

pub fn count_pivot_tables(&self) -> i32

Count existing pivot table parts in the package.

Source

pub fn count_pivot_cache(&self) -> i32

Count existing pivot cache parts in the package.

Source

pub fn count_slicers(&self) -> i32

Count existing slicer parts in the package.

Source

pub fn count_slicer_cache(&self) -> i32

Count existing slicer cache parts in the package.

Source

pub fn get_defined_names(&self) -> Result<Vec<DefinedName>>

Return all defined names in the workbook.

Source

pub fn set_defined_name(&self, dn: &DefinedName) -> Result<()>

Add a defined name.

Source

pub fn delete_defined_name(&self, dn: &DefinedName) -> Result<()>

Delete a defined name.

Source

pub fn get_defined_name_ref_to(&self, name: &str, current_sheet: &str) -> String

Return the reference a defined name resolves to.

Source

pub fn get_defined_name(&self) -> Result<Vec<DefinedName>>

Alias for Self::get_defined_names, matching the Go GetDefinedName API surface.

Source§

impl File

Source

pub fn write<W: Write>(&self, writer: W) -> Result<()>

Write the workbook to any writer. Alias for Self::write_to.

Source

pub fn save_with_options(&mut self, opts: Options) -> Result<()>

Save to the original path, overriding the stored options.

Source

pub fn save_as_with_options(&mut self, path: &str, opts: Options) -> Result<()>

Save the workbook to the given path, overriding the stored options.

Source

pub fn update_linked_value(&self) -> Result<()>

Clear cached linked values for formula cells so Excel recalculates them on open.

Equivalent to Go UpdateLinkedValue.

Source

pub fn read_zip_reader<R: Read + Seek>( &self, archive: &mut ZipArchive<R>, ) -> Result<(HashMap<String, Vec<u8>>, i32)>

Extract spreadsheet package parts from a ZipArchive.

Equivalent to Go ReadZipReader.

Source

pub fn set_workbook_props(&self, opts: &WorkbookPropsOptions) -> Result<()>

Set workbook properties.

Source

pub fn get_workbook_props(&self) -> Result<WorkbookPropsOptions>

Get workbook properties.

Source

pub fn set_calc_props(&self, opts: &CalcPropsOptions) -> Result<()>

Set calculation properties.

Source

pub fn get_calc_props(&self) -> Result<CalcPropsOptions>

Get calculation properties.

Source

pub fn protect_workbook(&self, opts: &WorkbookProtectionOptions) -> Result<()>

Protect the workbook with optional password and lock settings.

Source

pub fn unprotect_workbook(&self, password: Option<&str>) -> Result<()>

Remove workbook protection, optionally verifying the password first.

Source

pub fn add_vba_project(&self, data: &[u8]) -> Result<()>

Add a VBA project binary to the workbook.

The data must start with the OLE compound-file identifier. A valid vbaProject.bin can be embedded by reading it from disk and passing the bytes to this method. The workbook should be saved with an .xlsm or .xltm extension.

Source

pub fn set_content_type_part_project_extensions( &self, content_type: &str, ) -> Result<()>

Set the workbook content type and .bin default for macro workbooks.

Source§

impl File

Source

pub fn merge_cell( &self, sheet: &str, top_left: &str, bottom_right: &str, ) -> Result<()>

Merge a range of cells.

Source

pub fn unmerge_cell( &self, sheet: &str, top_left: &str, bottom_right: &str, ) -> Result<()>

Unmerge a range of cells.

Source

pub fn get_merge_cells(&self, sheet: &str) -> Result<Vec<String>>

Get all merged cell ranges in a worksheet.

Source§

impl File

Source

pub fn add_picture( &mut self, sheet: &str, cell: &str, path: &str, opts: Option<&GraphicOptions>, ) -> Result<()>

Add a picture to a worksheet from a file path.

Source

pub fn add_picture_from_bytes( &mut self, sheet: &str, cell: &str, pic: &Picture, ) -> Result<()>

Add a picture to a worksheet from raw bytes.

Source

pub fn get_pictures(&self, sheet: &str, cell: &str) -> Result<Vec<Picture>>

Return all pictures anchored at a given cell in a worksheet.

Source

pub fn get_picture_cells(&self, sheet: &str) -> Result<Vec<String>>

Return all picture cell references in a worksheet.

Equivalent to Go GetPictureCells.

Source§

impl File

Source

pub fn delete_picture(&mut self, sheet: &str, cell: &str) -> Result<()>

Delete all pictures in a cell.

Source§

impl File

Source

pub fn add_pivot_table(&self, opts: &mut PivotTableOptions) -> Result<()>

Add a pivot table.

Source

pub fn get_pivot_tables(&self, sheet: &str) -> Result<Vec<PivotTableOptions>>

Get pivot tables on a worksheet.

Source

pub fn delete_pivot_table(&self, sheet: &str, name: &str) -> Result<()>

Delete a pivot table.

Source§

impl File

Source

pub fn set_row_height(&self, sheet: &str, row: i32, height: f64) -> Result<()>

Set the height of a row.

Source

pub fn get_row_height(&self, sheet: &str, row: i32) -> Result<f64>

Get the height of a row.

Source

pub fn set_row_visible( &self, sheet: &str, row: i32, visible: bool, ) -> Result<()>

Set the visibility of a row.

Source

pub fn get_row_visible(&self, sheet: &str, row: i32) -> Result<bool>

Get the visibility of a row.

Source

pub fn set_row_outline_level( &self, sheet: &str, row: i32, level: u8, ) -> Result<()>

Set the outline level of a row.

Source

pub fn get_row_outline_level(&self, sheet: &str, row: i32) -> Result<u8>

Get the outline level of a row.

Source

pub fn insert_rows(&self, sheet: &str, row: i32, n: usize) -> Result<()>

Insert n rows before row.

Source

pub fn remove_row(&self, sheet: &str, row: i32) -> Result<()>

Remove a row.

Source

pub fn duplicate_row(&self, sheet: &str, row: i32) -> Result<()>

Duplicate a row.

Source

pub fn duplicate_row_to(&self, sheet: &str, row: i32, row2: i32) -> Result<()>

Duplicate a row to a target position, shifting existing rows down.

Equivalent to Go DuplicateRowTo.

Source

pub fn set_row_style( &self, sheet: &str, start: i32, end: i32, style_id: i32, ) -> Result<()>

Apply a style index to every cell in a range of rows.

This overwrites existing row and cell styles in the range; it does not merge with existing styles. The start and end row numbers are inclusive and will be swapped if end is less than start.

Source§

impl File

Source

pub fn rows(&self, sheet: &str) -> Result<Rows<'_>>

Return a streaming iterator over the rows of a worksheet.

Source

pub fn get_rows(&self, sheet: &str, opts: Options) -> Result<Vec<Vec<String>>>

Return all rows in a worksheet as a two-dimensional vector of strings.

Source§

impl File

Source

pub fn add_shape(&self, sheet: &str, opts: &Shape) -> Result<()>

Add a shape to a worksheet.

Source§

impl File

Source

pub fn get_sheet_list(&self) -> Vec<String>

Get a list of worksheet / chart / dialog sheet names.

Source

pub fn new_sheet(&self, name: &str) -> Result<i32>

Create a new worksheet.

Source

pub fn get_sheet_name(&self, index: i32) -> Result<String>

Get the worksheet name from a 1-based sheet index.

Source

pub fn get_sheet_index(&self, name: &str) -> Result<i32>

Get the 1-based sheet index of a worksheet by name.

Source

pub fn delete_sheet(&self, name: &str) -> Result<()>

Delete a worksheet by name.

Source

pub fn get_active_sheet_index(&self) -> Result<i32>

Get the index of the active worksheet (1-based).

Source

pub fn set_active_sheet(&self, index: i32) -> Result<()>

Set the active worksheet by 1-based index.

Source

pub fn set_sheet_props( &self, sheet: &str, opts: &SheetPropsOptions, ) -> Result<()>

Set worksheet properties.

Source

pub fn get_sheet_props(&self, sheet: &str) -> Result<SheetPropsOptions>

Get worksheet properties.

Source

pub fn set_sheet_view( &self, sheet: &str, view_index: i32, opts: &SheetViewOptions, ) -> Result<()>

Set worksheet view properties on the given sheet view. The view index may be negative and counts backward from the last view.

Source

pub fn get_sheet_view( &self, sheet: &str, view_index: i32, ) -> Result<SheetViewOptions>

Get worksheet view properties from the given sheet view. The view index may be negative and counts backward from the last view.

Source

pub fn set_page_layout( &self, sheet: &str, opts: &PageLayoutOptions, ) -> Result<()>

Set page layout properties.

Source

pub fn get_page_layout(&self, sheet: &str) -> Result<PageLayoutOptions>

Get page layout properties.

Source

pub fn set_page_margins( &self, sheet: &str, opts: &PageMarginsOptions, ) -> Result<()>

Set page margins.

Source

pub fn get_page_margins(&self, sheet: &str) -> Result<PageMarginsOptions>

Get page margins.

Set header/footer text.

Get header/footer text.

Source

pub fn set_sheet_name(&self, source: &str, target: &str) -> Result<()>

Set the worksheet name by given source and target worksheet names.

Source

pub fn set_sheet_background(&self, sheet: &str, picture: &str) -> Result<()>

Set background picture by given worksheet name and file path.

Source

pub fn set_sheet_background_from_bytes( &self, sheet: &str, extension: &str, picture: &[u8], ) -> Result<()>

Set background picture by given worksheet name, extension name and image data.

Source

pub fn move_sheet(&self, source: &str, target: &str) -> Result<()>

Move a sheet to a specified position in the workbook. Indices are 1-based and the source sheet is placed before the target sheet.

Source

pub fn copy_sheet(&self, from: i32, to: i32) -> Result<()>

Duplicate a worksheet by source and target 1-based sheet indices.

Source

pub fn set_sheet_visible( &self, sheet: &str, visible: bool, very_hidden: Option<bool>, ) -> Result<()>

Set worksheet visible by given worksheet name.

Source

pub fn get_sheet_visible(&self, sheet: &str) -> Result<bool>

Get worksheet visible by given worksheet name.

Source

pub fn set_panes(&self, sheet: &str, panes: &Panes) -> Result<()>

Create and remove freeze panes and split panes by given worksheet name and panes options.

Source

pub fn get_panes(&self, sheet: &str) -> Result<Panes>

Get freeze panes, split panes, and worksheet views by given worksheet name.

Source

pub fn search_sheet( &self, sheet: &str, value: &str, reg: Option<bool>, ) -> Result<Vec<String>>

Search cell reference by given worksheet name, cell value, and regular expression.

Source

pub fn protect_sheet( &self, sheet: &str, opts: &SheetProtectionOptions, ) -> Result<()>

Protect worksheet to prevent accidental or deliberate changes.

Source

pub fn unprotect_sheet(&self, sheet: &str, password: Option<&str>) -> Result<()>

Remove protection for a sheet.

Source

pub fn get_sheet_protection( &self, sheet: &str, ) -> Result<SheetProtectionOptions>

Get worksheet protection settings by given worksheet name.

Source

pub fn group_sheets(&self, sheets: &[String]) -> Result<()>

Group worksheets by given worksheet names.

Source

pub fn ungroup_sheets(&self) -> Result<()>

Ungroup worksheets.

Source

pub fn insert_page_break(&self, sheet: &str, cell: &str) -> Result<()>

Create a page break by given worksheet name and cell reference.

Source

pub fn remove_page_break(&self, sheet: &str, cell: &str) -> Result<()>

Remove a page break by given worksheet name and cell reference.

Source

pub fn set_sheet_dimension(&self, sheet: &str, range_ref: &str) -> Result<()>

Set or remove the used range of the worksheet by a given range reference.

Source

pub fn get_sheet_dimension(&self, sheet: &str) -> Result<String>

Get the used range of the worksheet.

Source

pub fn add_ignored_errors( &self, sheet: &str, range_ref: &str, ignored_errors_type: IgnoredErrorsType, ) -> Result<()>

Ignore error for a range of cells.

Source§

impl File

Source

pub fn get_sheet_name_to_path_map(&self) -> Result<HashMap<String, String>>

Build a map of worksheet name → XML path from the workbook and its rels.

Source

pub fn get_sheet_map(&self) -> HashMap<i32, String>

Get worksheets, chart sheets and dialog sheets ID and name map of the workbook.

Source

pub fn rel_id_to_sheet_id(&self, r_id: &str) -> Result<i32>

Convert a relationship id to a 0-based sheet index.

Source§

impl File

Source

pub fn add_slicer(&self, sheet: &str, opts: &SlicerOptions) -> Result<()>

AddSlicer inserts a slicer by giving the worksheet name and slicer settings.

Source

pub fn get_slicers(&self, sheet: &str) -> Result<Vec<SlicerOptions>>

GetSlicers provides all slicers in a worksheet by a given worksheet name.

Source

pub fn delete_slicer(&self, name: &str) -> Result<()>

DeleteSlicer deletes a slicer by a given slicer name.

Source§

impl File

Source

pub fn add_sparkline(&self, sheet: &str, opts: &SparklineOptions) -> Result<()>

Add sparklines to a worksheet.

Sparklines are small charts that fit in a single cell and are used to show trends in data. Sparklines are a feature of Excel 2010 and later only.

Source§

impl File

Source

pub fn new_stream_writer(&self, sheet: &str) -> Result<StreamWriter<'_>>

Create a new stream writer for the given worksheet.

Source§

impl File

Source

pub fn new_style(&self, style: &Style) -> Result<i32>

Create a new cell style and return its style ID.

Equivalent to Go NewStyle.

Source

pub fn get_style(&self, style_id: i32) -> Result<Style>

Get the style definition for a given style ID.

Equivalent to Go GetStyle.

Source

pub fn get_default_font(&self) -> Result<String>

Return the default font name in the workbook.

Equivalent to Go GetDefaultFont.

Source

pub fn set_default_font(&self, font_name: &str) -> Result<()>

Change the default font in the workbook.

Equivalent to Go SetDefaultFont.

Source

pub fn new_conditional_style(&self, style: &Style) -> Result<i32>

Create a new style for conditional formats and return its dxf ID.

Equivalent to Go NewConditionalStyle.

Source

pub fn get_conditional_style(&self, style_id: i32) -> Result<Style>

Get the conditional format style definition for a given dxf ID.

Equivalent to Go GetConditionalStyle.

Source

pub fn set_conditional_format( &self, sheet: &str, range_ref: &str, opts: &[ConditionalFormatOptions], ) -> Result<()>

Create conditional formatting rules for a range of cells.

Equivalent to Go SetConditionalFormat.

Source

pub fn get_conditional_formats( &self, sheet: &str, ) -> Result<HashMap<String, Vec<ConditionalFormatOptions>>>

Return conditional format settings by worksheet name.

Equivalent to Go GetConditionalFormats.

Source

pub fn unset_conditional_format( &self, sheet: &str, range_ref: &str, ) -> Result<()>

Unset conditional formats for a range of cells.

Equivalent to Go UnsetConditionalFormat.

Source

pub fn get_base_color( &self, hex_color: &str, indexed_color: i64, theme_color: Option<i64>, ) -> String

Return the preferred hex color code from a hex color, indexed color, or theme color.

Equivalent to Go GetBaseColor.

Source§

impl File

Source

pub fn add_table(&self, sheet: &str, table: Option<&Table>) -> Result<()>

Add a table to a worksheet.

Source

pub fn get_tables(&self, sheet: &str) -> Result<Vec<Table>>

Get the tables in a worksheet.

Source

pub fn delete_table(&self, name: &str) -> Result<()>

Delete a table by name.

Source

pub fn auto_filter( &self, sheet: &str, range_ref: &str, opts: &[AutoFilterOptions], ) -> Result<()>

Apply an AutoFilter to a worksheet range.

Source§

impl File

Source

pub fn get_comments(&self, sheet: &str) -> Result<Vec<Comment>>

Retrieve all comments in a worksheet.

Source

pub fn add_comment(&self, sheet: &str, opts: Comment) -> Result<()>

Add a comment to a worksheet.

Source

pub fn delete_comment(&self, sheet: &str, cell: &str) -> Result<()>

Delete a comment in a worksheet by cell reference.

Source

pub fn add_form_control(&self, sheet: &str, opts: FormControl) -> Result<()>

Add a form control to a worksheet.

Source

pub fn delete_form_control(&self, sheet: &str, cell: &str) -> Result<()>

Delete a form control in a worksheet by cell reference.

Source

pub fn get_form_controls(&self, sheet: &str) -> Result<Vec<FormControl>>

Retrieve all form controls in a worksheet.

Add an image that can be referenced from the worksheet header/footer.

Trait Implementations§

Source§

impl Debug for File

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for File

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl ExcelizeCore for File

Source§

fn check_sheet_name(name: &str) -> Result<()>

Validate that a worksheet name is legal.
Source§

fn check_open_reader_options(&self) -> Result<()>

Validate options used when opening a reader.
Source§

fn work_sheet_reader(&self, sheet: &str) -> Result<XlsxWorksheet>

Deserialize and return a worksheet by name.
Source§

fn update_linked_value(&self) -> Result<()>

Update linked cell values so Excel recalculates them on open.
Source§

fn add_vba_project(&self, data: &[u8]) -> Result<()>

Add a VBA project binary to the workbook.
Source§

fn set_content_type_part_project_extensions( &self, content_type: &str, ) -> Result<()>

Set the workbook content type and .bin default for macro workbooks.
Source§

fn set_workbook_props(&self, opts: &WorkbookPropsOptions) -> Result<()>

Set workbook properties.
Source§

fn get_workbook_props(&self) -> Result<WorkbookPropsOptions>

Get workbook properties.
Source§

fn set_calc_props(&self, opts: &CalcPropsOptions) -> Result<()>

Set calculation properties.
Source§

fn get_calc_props(&self) -> Result<CalcPropsOptions>

Get calculation properties.
Source§

fn protect_workbook(&self, opts: &WorkbookProtectionOptions) -> Result<()>

Protect the workbook.
Source§

fn unprotect_workbook(&self, password: Option<&str>) -> Result<()>

Remove workbook protection, optionally verifying the password.

Auto Trait Implementations§

§

impl !Freeze for File

§

impl !RefUnwindSafe for File

§

impl !Sync for File

§

impl Send for File

§

impl Unpin for File

§

impl UnsafeUnpin for File

§

impl UnwindSafe for File

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V