Skip to main content

Crate rustypyxl

Crate rustypyxl 

Source
Expand description

rustypyxl: Fast Rust library for reading and writing Excel xlsx files.

This crate provides the functionality for working with Excel files without any Python dependencies. The rustypyxl package on PyPI is a PyO3 binding over this same library, exposing an openpyxl-compatible API.

§Example

use rustypyxl::{Workbook, CellValue};

// Create a new workbook
let mut wb = Workbook::new();
let ws = wb.create_sheet(Some("Data".to_string())).unwrap();

// Set cell values
wb.set_cell_value_in_sheet("Data", 1, 1, CellValue::from("Hello")).unwrap();
wb.set_cell_value_in_sheet("Data", 1, 2, CellValue::Number(42.0)).unwrap();

// Save the workbook
wb.save("output.xlsx").unwrap();

// Load an existing workbook
let wb = Workbook::load("input.xlsx").unwrap();
let ws = wb.active().unwrap();
println!("Sheet title: {}", ws.title());

Re-exports§

pub use cell::CellValue;
pub use error::Result;
pub use error::RustypyxlError;
pub use formula::evaluate as evaluate_formula;
pub use formula::CellResolver;
pub use formula::FormulaValue;
pub use numfmt::builtin_format_code;
pub use numfmt::format_number;
pub use numfmt::format_value;
pub use rich_text::RichText;
pub use rich_text::RunFont;
pub use rich_text::TextRun;
pub use style::Alignment;
pub use style::Border;
pub use style::BorderStyle;
pub use style::CellStyle;
pub use style::Color;
pub use style::Fill;
pub use style::Font;
pub use style::GradientFill;
pub use style::GradientStop;
pub use style::Protection;
pub use utils::column_to_letter;
pub use utils::coordinate_from_row_col;
pub use utils::letter_to_column;
pub use utils::parse_coordinate;
pub use utils::parse_coordinate_bytes;
pub use utils::parse_f64_bytes;
pub use utils::parse_range;
pub use utils::parse_u32_bytes;
pub use workbook::CompressionLevel;
pub use workbook::NamedRange;
pub use workbook::Workbook;
pub use worksheet::CellData;
pub use worksheet::DataValidation;
pub use worksheet::SheetVisibility;
pub use worksheet::Worksheet;
pub use worksheet::WorksheetProtection;

Modules§

autofilter
AutoFilter support for Excel workbooks.
cell
Cell value types and utilities.
chart
Chart support for Excel workbooks.
chart_writer
Serialize charts to the OOXML parts a saved workbook needs: the chart definition (xl/charts/chartN.xml) and the drawing that anchors it on a sheet (xl/drawings/drawingM.xml). Write-path only; reading charts back on load is a separate concern.
conditional
Conditional formatting support for Excel workbooks.
drawing_writer
Serialize a sheet’s drawing part (xl/drawings/drawingN.xml): the anchors for its charts (a graphicFrame referencing a chart part) and its images (a pic referencing an embedded media part), plus the relationship rows the drawing’s .rels part binds those references to.
error
Error types for rustypyxl.
formula
A small formula evaluation engine: tokenizer, precedence parser, and evaluator for the common subset of Excel formulas.
image
Image support for Excel workbooks.
numfmt
Render a value under an Excel number-format code to the string Excel would display for it. Excel stores only the format code (e.g. "0.00%", "yyyy-mm-dd", "#,##0.00;[Red](#,##0.00)"); this module interprets that code so readers can show data the way Excel does without re-implementing the rules per caller.
pagesetup
Page setup and print settings for Excel worksheets.
pivot
Read-only pivot-table model. Pivot tables are preserved verbatim on save (see crate::workbook::PivotArtifacts); this module parses those raw parts into a structured view – source range, cache fields, and the field placements (row/column/data/page areas) – matching openpyxl’s read support. It does not build or write pivot tables.
rich_text
Rich text: a cell string whose runs carry their own formatting.
streaming
Streaming write support for memory-efficient Excel file creation.
style
Cell styling types: Font, Fill, Border, Alignment, CellStyle.
table
Excel Table (ListObject) support.
utils
Utility functions for coordinate parsing and conversion.
workbook
Workbook representation and file I/O operations.
worksheet
Worksheet representation and cell operations.
writer