spreadsheet_mcp/analysis/
style.rs

1use umya_spreadsheet::Cell;
2
3#[derive(Debug, Clone)]
4pub struct StyleTagging {
5    pub tags: Vec<String>,
6    pub example_cell: String,
7}
8
9pub fn tag_cell(cell: &Cell) -> Option<(String, StyleTagging)> {
10    let style = cell.get_style();
11    let mut tags = Vec::new();
12
13    if let Some(font) = style.get_font() {
14        if *font.get_bold() {
15            tags.push("header".to_string());
16        }
17        if *font.get_italic() {
18            tags.push("emphasis".to_string());
19        }
20    }
21
22    if let Some(number_format) = style.get_number_format() {
23        let format_code = number_format.get_format_code().to_ascii_lowercase();
24        if format_code.contains("$") {
25            tags.push("currency".to_string());
26        } else if format_code.contains("%") {
27            tags.push("percentage".to_string());
28        } else if format_code.contains("yy") {
29            tags.push("date".to_string());
30        }
31    }
32
33    if tags.is_empty() {
34        return None;
35    }
36
37    let coordinate = cell.get_coordinate();
38    let address = coordinate.get_coordinate();
39    let key = tags.join("|");
40
41    Some((
42        key,
43        StyleTagging {
44            tags,
45            example_cell: address,
46        },
47    ))
48}