#excel #xlsx #string-formatting #api-bindings

xlsxwriter

Write xlsx file with number, formula, string, formatting, autofilter, merged cells, data validation and more

12 releases

0.6.1 Jun 22, 2024
0.6.0 Apr 11, 2023
0.5.0 Nov 13, 2022
0.3.5 Jul 13, 2021
0.2.0 Nov 19, 2019

#97 in Encoding

Download history 6486/week @ 2024-04-05 6737/week @ 2024-04-12 6027/week @ 2024-04-19 5381/week @ 2024-04-26 5667/week @ 2024-05-03 7000/week @ 2024-05-10 7398/week @ 2024-05-17 5546/week @ 2024-05-24 7156/week @ 2024-05-31 5978/week @ 2024-06-07 5719/week @ 2024-06-14 6725/week @ 2024-06-21 4963/week @ 2024-06-28 5926/week @ 2024-07-05 5580/week @ 2024-07-12 3993/week @ 2024-07-19

21,613 downloads per month
Used in 16 crates (13 directly)

Apache-2.0

2.5MB
47K SLoC

C 40K SLoC // 0.2% comments Rust 5.5K SLoC // 0.0% comments Bitbake 526 SLoC Shell 431 SLoC // 0.2% comments Zig 282 SLoC // 0.1% comments Perl 236 SLoC // 0.2% comments C++ 63 SLoC // 0.1% comments Swift 37 SLoC Automake 33 SLoC

xlsxwriter-rs

Build GitHub GitHub top language Crates.io Docs.rs

Rust binding of libxlsxwriter

Supported Features

  • 100% compatible Excel XLSX files.
  • Full Excel formatting.
  • Merged cells.
  • Autofilters.
  • Data validation and drop down lists.
  • Worksheet PNG/JPEG images.

Coming soon

  • Charts.

Feature Flags

  • no-md5: Disable image de-duplication and remove md5 function. (See upstream document to learn more).
  • use-openssl-md5: Use OpenSSL implementation of md5 function. (See upstream document to learn more).
  • system-zlib: Use system zlib instead of included zlib.

Build requirements

  • LLVM and clang

How to build on windows

  1. Install Visual Studio
  2. Install LLVM
  3. Set environment variable LIBCLANG_PATH as C:\Program Files\LLVM\bin
  4. Run build

Example

Result Image

let workbook = Workbook::new("simple1.xlsx")?;

let mut sheet1 = workbook.add_worksheet(None)?;
sheet1.write_string(0, 0, "Red text", Some(&Format::new().set_font_color(FormatColor::Red)))?;
sheet1.write_number(0, 1, 20., None)?;
sheet1.write_formula_num(1, 0, "=10+B1", None, 30.)?;
sheet1.write_url(
    1,
    1,
    "https://github.com/informationsea/xlsxwriter-rs",
    Some(&Format::new().set_font_color(FormatColor::Blue).set_underline(FormatUnderline::Single)),
)?;
sheet1.merge_range(2, 0, 3, 2, "Hello, world", Some(
    &Format::new().set_font_color(FormatColor::Green).set_align(FormatAlignment::CenterAcross)
                  .set_vertical_align(FormatVerticalAlignment::VerticalCenter)))?;

sheet1.set_selection(1, 0, 1, 2);
sheet1.set_tab_color(FormatColor::Cyan);
workbook.close()?;

Run Example with Cargo

You can explore this example locally following the steps below:

  1. Install LLVM and set LIBCLANG_PATH if you are using windows. (see bindgen doc for details)
  2. clone or fork this repository
  3. git submodule update --init --recursive
    • The above command downloads the required C library so we can compile
  4. cargo run --example hello_spreadsheet

You should then see the example in target/simple1.xlsx. Enjoy!

Dependencies