pub struct IgnoredError {
pub range: String,
pub number_stored_as_text: bool,
pub formula_range: bool,
pub formula: bool,
pub unlocked_formula: bool,
pub empty_cell_reference: bool,
pub list_data_validation: bool,
pub calculated_column: bool,
pub two_digit_text_year: bool,
pub eval_error: bool,
}Expand description
A suppressed error-checking indicator over one range (<ignoredError>, CT_IgnoredError).
Confirmed against sml.xsd (CT_IgnoredErrors/CT_IgnoredError, ECMA-376 SpreadsheetML):
sqref is the only required attribute, every error-category flag is an optional boolean
defaulting to false. This crate models every flag CT_IgnoredError defines; real Excel’s own
“Ignore Error” right-click menu only ever sets one flag at a time per range, but nothing in the
schema forbids several flags on the same entry, so this type allows it too (caller’s choice,
same “don’t second-guess the caller” posture as ConditionalFormattingRule).
Fields§
§range: StringThe range this entry covers (sqref, e.g. "B2:B10" or a single cell "C4") — like
ConditionalFormattingRule::range, several disjoint cells can be packed into one sqref
(space-separated) if the caller wants a single entry to cover them; this crate writes the
string verbatim, no validation.
number_stored_as_text: boolSuppresses the “number stored as text” warning — by far the most common real-world use of
<ignoredError> (e.g. a column of ZIP codes or reference numbers intentionally kept as
text).
formula_range: boolSuppresses the “formula omits adjacent cells” warning.
formula: boolSuppresses the “inconsistent formula” warning (a formula that differs from the pattern of its neighboring cells).
unlocked_formula: boolSuppresses the “unlocked cell containing a formula” warning.
empty_cell_reference: boolSuppresses the “formula refers to an empty cell” warning.
list_data_validation: boolSuppresses the “value fails a list data validation rule” warning.
calculated_column: boolSuppresses the “table’s calculated column formula is inconsistent” warning.
two_digit_text_year: boolSuppresses the “text year is ambiguous” warning (a two-digit year entered in a text-formatted cell).
eval_error: boolSuppresses the “formula results in an error” warning (e.g. a deliberate #N/A or
#DIV/0!).
Implementations§
Source§impl IgnoredError
impl IgnoredError
Sourcepub fn new(range: impl Into<String>) -> IgnoredError
pub fn new(range: impl Into<String>) -> IgnoredError
Creates an ignored-error entry over range with every flag unset — use the with_*
builders to enable the specific warning(s) to suppress.
Examples found in repository?
16fn main() -> office_toolkit::Result<()> {
17 let path = output_path("xlsx_workbook_metadata.xlsx");
18
19 let named_ranges_sheet = Sheet::new("Named ranges")
20 .with_row(Row::new().with_text("Tax rate").with_number(0.0825))
21 .with_row(Row::new().with_cell(Cell::formula("TaxRate*100").with_cached_value(8.25)));
22
23 let calculation_sheet = Sheet::new("Calculation").with_row(
24 Row::new().with_text("Set to manual recalculation with iterative calculation enabled."),
25 );
26
27 let scenarios_sheet = Sheet::new("Scenarios")
28 .with_row(Row::new().with_text("Revenue").with_number(100_000.0))
29 .with_row(Row::new().with_text("Cost").with_number(60_000.0))
30 .with_scenario(
31 Scenario::new("Best case")
32 .with_input("B1", "150000")
33 .with_input("B2", "55000")
34 .with_comment("Optimistic projection"),
35 )
36 .with_scenario(
37 Scenario::new("Worst case")
38 .with_input("B1", "70000")
39 .with_input("B2", "65000"),
40 );
41
42 let auto_filter_sheet = Sheet::new("Autofilter criteria")
43 .with_row(Row::new().with_text("Region"))
44 .with_row(Row::new().with_text("North"))
45 .with_row(Row::new().with_text("South"))
46 .with_auto_filter_range("A1:A3")
47 .with_auto_filter_column(AutoFilterColumn::new(0, vec!["North".to_string()]));
48
49 let ignored_errors_sheet = Sheet::new("Ignored errors")
50 .with_row(Row::new().with_text("123")) // a number stored as text — normally flagged by Excel
51 .with_ignored_error(IgnoredError::new("A1:A1").with_number_stored_as_text(true));
52
53 let workbook = Workbook::new()
54 .with_defined_name(DefinedName::new("TaxRate", "'Named ranges'!$B$1"))
55 .with_calculation(
56 CalculationProperties::new()
57 .with_mode(CalculationMode::Manual)
58 .with_iterate(true),
59 )
60 .with_sheet(named_ranges_sheet)
61 .with_sheet(calculation_sheet)
62 .with_sheet(scenarios_sheet)
63 .with_sheet(auto_filter_sheet)
64 .with_sheet(ignored_errors_sheet);
65
66 // `Workbook.properties` has no `with_*` builder — it's set directly,
67 // like any other public field.
68 let properties = DocumentProperties::new()
69 .with_title("Metadata example")
70 .with_author("Example Author")
71 .with_subject("Workbook-level features")
72 .with_custom_property(
73 "ProjectCode",
74 CustomPropertyValue::Text("XLSX-META".to_string()),
75 );
76 let workbook = Workbook {
77 properties,
78 ..workbook
79 };
80
81 workbook.save_to_file(&path)?;
82 println!("Wrote {}", path.display());
83 Ok(())
84}Sourcepub fn with_number_stored_as_text(self, value: bool) -> IgnoredError
pub fn with_number_stored_as_text(self, value: bool) -> IgnoredError
Suppresses the “number stored as text” warning and returns the entry for chaining — the common case (see this type’s own doc comment).
Examples found in repository?
16fn main() -> office_toolkit::Result<()> {
17 let path = output_path("xlsx_workbook_metadata.xlsx");
18
19 let named_ranges_sheet = Sheet::new("Named ranges")
20 .with_row(Row::new().with_text("Tax rate").with_number(0.0825))
21 .with_row(Row::new().with_cell(Cell::formula("TaxRate*100").with_cached_value(8.25)));
22
23 let calculation_sheet = Sheet::new("Calculation").with_row(
24 Row::new().with_text("Set to manual recalculation with iterative calculation enabled."),
25 );
26
27 let scenarios_sheet = Sheet::new("Scenarios")
28 .with_row(Row::new().with_text("Revenue").with_number(100_000.0))
29 .with_row(Row::new().with_text("Cost").with_number(60_000.0))
30 .with_scenario(
31 Scenario::new("Best case")
32 .with_input("B1", "150000")
33 .with_input("B2", "55000")
34 .with_comment("Optimistic projection"),
35 )
36 .with_scenario(
37 Scenario::new("Worst case")
38 .with_input("B1", "70000")
39 .with_input("B2", "65000"),
40 );
41
42 let auto_filter_sheet = Sheet::new("Autofilter criteria")
43 .with_row(Row::new().with_text("Region"))
44 .with_row(Row::new().with_text("North"))
45 .with_row(Row::new().with_text("South"))
46 .with_auto_filter_range("A1:A3")
47 .with_auto_filter_column(AutoFilterColumn::new(0, vec!["North".to_string()]));
48
49 let ignored_errors_sheet = Sheet::new("Ignored errors")
50 .with_row(Row::new().with_text("123")) // a number stored as text — normally flagged by Excel
51 .with_ignored_error(IgnoredError::new("A1:A1").with_number_stored_as_text(true));
52
53 let workbook = Workbook::new()
54 .with_defined_name(DefinedName::new("TaxRate", "'Named ranges'!$B$1"))
55 .with_calculation(
56 CalculationProperties::new()
57 .with_mode(CalculationMode::Manual)
58 .with_iterate(true),
59 )
60 .with_sheet(named_ranges_sheet)
61 .with_sheet(calculation_sheet)
62 .with_sheet(scenarios_sheet)
63 .with_sheet(auto_filter_sheet)
64 .with_sheet(ignored_errors_sheet);
65
66 // `Workbook.properties` has no `with_*` builder — it's set directly,
67 // like any other public field.
68 let properties = DocumentProperties::new()
69 .with_title("Metadata example")
70 .with_author("Example Author")
71 .with_subject("Workbook-level features")
72 .with_custom_property(
73 "ProjectCode",
74 CustomPropertyValue::Text("XLSX-META".to_string()),
75 );
76 let workbook = Workbook {
77 properties,
78 ..workbook
79 };
80
81 workbook.save_to_file(&path)?;
82 println!("Wrote {}", path.display());
83 Ok(())
84}Sourcepub fn with_formula_range(self, value: bool) -> IgnoredError
pub fn with_formula_range(self, value: bool) -> IgnoredError
Suppresses the “formula omits adjacent cells” warning and returns the entry for chaining.
Sourcepub fn with_formula(self, value: bool) -> IgnoredError
pub fn with_formula(self, value: bool) -> IgnoredError
Suppresses the “inconsistent formula” warning and returns the entry for chaining.
Sourcepub fn with_unlocked_formula(self, value: bool) -> IgnoredError
pub fn with_unlocked_formula(self, value: bool) -> IgnoredError
Suppresses the “unlocked cell containing a formula” warning and returns the entry for chaining.
Sourcepub fn with_empty_cell_reference(self, value: bool) -> IgnoredError
pub fn with_empty_cell_reference(self, value: bool) -> IgnoredError
Suppresses the “formula refers to an empty cell” warning and returns the entry for chaining.
Sourcepub fn with_list_data_validation(self, value: bool) -> IgnoredError
pub fn with_list_data_validation(self, value: bool) -> IgnoredError
Suppresses the “value fails a list data validation rule” warning and returns the entry for chaining.
Sourcepub fn with_calculated_column(self, value: bool) -> IgnoredError
pub fn with_calculated_column(self, value: bool) -> IgnoredError
Suppresses the “table’s calculated column formula is inconsistent” warning and returns the entry for chaining.
Sourcepub fn with_two_digit_text_year(self, value: bool) -> IgnoredError
pub fn with_two_digit_text_year(self, value: bool) -> IgnoredError
Suppresses the “text year is ambiguous” warning and returns the entry for chaining.
Sourcepub fn with_eval_error(self, value: bool) -> IgnoredError
pub fn with_eval_error(self, value: bool) -> IgnoredError
Suppresses the “formula results in an error” warning and returns the entry for chaining.
Trait Implementations§
Source§impl Clone for IgnoredError
impl Clone for IgnoredError
Source§fn clone(&self) -> IgnoredError
fn clone(&self) -> IgnoredError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more