Crate xlsxwriter[][src]

xlsxwriter-rs

Rust binding of libxlsxwriter

** API of this library is not stable. **

Supported Features

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

Coming soon

  • Charts.

Examples

Result Image

use xlsxwriter::*;

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

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

let mut 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()?;

Please read original libxlsxwriter document for description missing functions. Most of this document is based on libxlsxwriter document.

Structs

Chart

The Chart object represents an Excel chart. It provides functions for adding data series to the chart and for configuring the chart.

ChartFill

Struct to represent a chart fill.

ChartLine

Struct to represent a chart line.

ChartPattern

Struct to represent a chart pattern.

ChartSeries

Struct to represent an Excel chart data series. This struct is created using the chart.add_series() function. It is used in functions that modify a chart series but the members of the struct aren’t modified directly.

DataValidation
DateTime
Format

This Format object has the functions and properties that are available for formatting cells in Excel.

HeaderFooterOptions
ImageOptions

Options for modifying images inserted via Worksheet.insert_image_opt().

Protection
Workbook

The Workbook is the main object exposed by the libxlsxwriter library. It represents the entire spreadsheet as you see it in Excel and internally it represents the Excel file as it is written on disk.

Worksheet

The Worksheet object represents an Excel worksheet. It handles operations such as writing data to cells or formatting worksheet layout.

XlsxError

Enums

ChartDashType
ChartMarkerType
ChartPatternType
ChartType
DataValidationCriteria
DataValidationErrorType
DataValidationType
FormatAlignment
FormatBorder
FormatColor
FormatPatterns
FormatScript
FormatUnderline
GridLines
PaperType

Type Definitions

CommentOptions
RowColOptions
WorksheetCol

Integer data type to represent a row value. Equivalent to u32.

WorksheetRow

Integer data type to represent a column value. Equivalent to u16.