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.
Sample Code
Section titled βSample Codeβuse draviavemal_openxml_office::spreadsheet_2007::models::{CellProperty, CellStyleSetting};
// Register styles and keep the returned idslet 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 cellsheet.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");// Register a style and keep the returned idStyleId styleId = excel.GetStyleId(new CellStyleSetting(){CustomNumberFormat = "00.000",FontSize = 20,});// Apply the style id to a cellworksheet.SetCellRefValues("A1", new CellProperty[1]{new(){ Value = "2.51", DataType = CellDataType.Number, StyleId = styleId }});CellStyleSetting Options
Section titled βCellStyleSetting OptionsβThe setters below are currently available and covered by the test suites.
| Rust | C# | Type | Details |
|---|---|---|---|
set_is_bold(value) | IsBold | bool | Bold cell content |
set_is_italic(value) | IsItalic | bool | Italic cell content |
set_is_underline(value) | IsUnderline | bool | Underline cell content |
set_is_double_underline(value) | IsDoubleUnderline | bool | Double underline cell content |
set_is_wrap_text(value) | IsWrapText | bool | Auto-wrap cell content |
| β | FontSize | uint | Font size of the cell content |
| β | CustomNumberFormat | string | Number format for the cell content |