#excel #xlsx #ffi

sys libxlsxwriter-sys

Rust binding of libxlsxwriter

6 releases (stable)

1.1.1 Jul 13, 2021
1.0.6 Jun 20, 2021
1.0.2 Apr 18, 2021
1.0.0 Sep 24, 2020
0.8.7 Nov 17, 2019

#171 in Filesystem

Download history 266/week @ 2021-04-02 562/week @ 2021-04-09 497/week @ 2021-04-16 451/week @ 2021-04-23 418/week @ 2021-04-30 364/week @ 2021-05-07 456/week @ 2021-05-14 405/week @ 2021-05-21 355/week @ 2021-05-28 509/week @ 2021-06-04 405/week @ 2021-06-11 476/week @ 2021-06-18 355/week @ 2021-06-25 139/week @ 2021-07-02 346/week @ 2021-07-09 441/week @ 2021-07-16

1,658 downloads per month
Used in 3 crates (via xlsxwriter)

MIT license

2MB
40K SLoC

C 39K SLoC // 0.2% comments Shell 425 SLoC // 0.2% comments Perl 234 SLoC // 0.2% comments Rust 114 SLoC // 0.0% comments Automake 34 SLoC

xlsxwriter-rs

Build Build Status Build status 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.

Build requirements

  • LLVM and clang

Example

Result Image

let workbook = Workbook::new("target/simple1.xlsx");
let format1 = workbook.add_format().set_font_color(FormatColor::Red);

let format2 = workbook
    .add_format()
    .set_font_color(FormatColor::Blue)
    .set_underline(FormatUnderline::Single);

let format3 = workbook
    .add_format()
    .set_font_color(FormatColor::Green)
    .set_align(FormatAlignment::CenterAcross)
    .set_align(FormatAlignment::VerticalCenter);

let mut sheet1 = workbook.add_worksheet(None)?;
sheet1.write_string(0, 0, "Red text", Some(&format1))?;
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(&format2),
)?;
sheet1.merge_range(2, 0, 3, 2, "Hello, world", Some(&format3))?;

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!

No runtime deps

~0–1.5MB
~33K SLoC