Rust binding of libxlsxwriter
- 100% compatible Excel XLSX files.
- Full Excel formatting.
- Merged cells.
- Autofilters.
- Data validation and drop down lists.
- Worksheet PNG/JPEG images.
Coming soon
- Charts.
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.
- LLVM and clang
- Install Visual Studio
- Install LLVM
- Set environment variable
LIBCLANG_PATH
asC:\Program Files\LLVM\bin
- Run build
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()?;
You can explore this example locally following the steps below:
- Install LLVM and set LIBCLANG_PATH if you are using windows. (see bindgen doc for details)
- clone or fork this repository
git submodule update --init --recursive
- The above command downloads the required C library so we can compile
cargo run --example hello_spreadsheet
You should then see the example in target/simple1.xlsx
. Enjoy!