1use ironcalc_base::Model;
2
3pub fn get_metadata_sheet_index(model: &Model) -> Option<u32> {
4 for (index, ws) in model.workbook.worksheets.iter().enumerate() {
5 if ws.name.eq_ignore_ascii_case("METADATA") {
6 return Some(index as u32);
7 }
8 }
9 None
10}
11
12pub fn get_workbook_metadata(model: &Model) -> String {
14 let metadata_sheet_index = get_metadata_sheet_index(model);
15 let default_locale = "en".to_string();
16 if let Some(sheet_index) = metadata_sheet_index {
17 if let Ok(a1) = model.get_formatted_cell_value(sheet_index, 1, 1) {
18 if a1 == "Locale" {
19 match model.get_formatted_cell_value(sheet_index, 1, 2) {
20 Ok(v) if v == "en-GB" => {
21 return "en-GB".to_string();
22 }
23 _ => return default_locale,
24 }
25 }
26 }
27 }
28 default_locale
29}