Skip to content

This content is for v4.x version. Switch to the Stable version.

Style

Style is instance object per excel created to maintain for performance of the document creation process. This instance provides a common handle to set a style combination once refer it across the spreadsheet.

It is highly recommended to use this strategy and reduce the number of cycle the openXMLOffice.Excel cell row insert life take to find the style id for the repeated setting you are making using the cell style property. Use the styleId thats given as response from this object to optimize the document creation process.

use draviavemal_openxml_office::spreadsheet_2007::models::{CellProperty, CellStyleSetting};
// Register styles and keep the returned ids
let bold_id = file
.get_style_id_mut(CellStyleSetting::default().set_is_bold(true))
.expect("Failed to get style id");
let wrap_id = file
.get_style_id_mut(CellStyleSetting::default().set_is_wrap_text(true))
.expect("Failed to get style id");
// Apply the style id to a cell
sheet.set_cell_ref_value_mut(
"A1",
vec![
CellProperty::default()
.set_value(Some("Bold".to_string()))
.set_style_id(Some(bold_id)),
],
).expect("Failed to set value");

The setters below are currently available and covered by the test suites.

RustC#TypeDetails
set_is_bold(value)IsBoldboolBold cell content
set_is_italic(value)IsItalicboolItalic cell content
set_is_underline(value)IsUnderlineboolUnderline cell content
set_is_double_underline(value)IsDoubleUnderlineboolDouble underline cell content
set_is_wrap_text(value)IsWrapTextboolAuto-wrap cell content
β€”FontSizeuintFont size of the cell content
β€”CustomNumberFormatstringNumber format for the cell content