committed by
Nicolás Hatcher Andrés
parent
b9b3cb1628
commit
faa0ff9b69
@@ -336,6 +336,7 @@ fn get_cell_from_excel(
|
||||
sheet_name: &str,
|
||||
cell_ref: &str,
|
||||
shared_strings: &mut Vec<String>,
|
||||
rich_text_inline: Option<String>,
|
||||
) -> Cell {
|
||||
// Possible cell types:
|
||||
// 18.18.11 ST_CellType (Cell Type)
|
||||
@@ -397,12 +398,15 @@ fn get_cell_from_excel(
|
||||
}
|
||||
}
|
||||
"inlineStr" => {
|
||||
// Not implemented
|
||||
println!("Invalid type (inlineStr) in {sheet_name}!{cell_ref}");
|
||||
Cell::ErrorCell {
|
||||
ei: Error::NIMPL,
|
||||
s: cell_style,
|
||||
}
|
||||
let s = rich_text_inline.unwrap_or_default();
|
||||
let si = if let Some(i) = shared_strings.iter().position(|r| r == &s) {
|
||||
i
|
||||
} else {
|
||||
shared_strings.push(s.to_string());
|
||||
shared_strings.len() - 1
|
||||
} as i32;
|
||||
|
||||
Cell::SharedString { si, s: cell_style }
|
||||
}
|
||||
"empty" => Cell::EmptyCell { s: cell_style },
|
||||
_ => {
|
||||
@@ -480,16 +484,11 @@ fn get_cell_from_excel(
|
||||
}
|
||||
}
|
||||
"inlineStr" => {
|
||||
// Not implemented
|
||||
let o = format!("{sheet_name}!{cell_ref}");
|
||||
let m = Error::NIMPL.to_string();
|
||||
println!("Invalid type (inlineStr) in {sheet_name}!{cell_ref}");
|
||||
Cell::CellFormulaError {
|
||||
// NB: This is untested, I don't know of any engine that uses inline strings in formulas
|
||||
Cell::CellFormulaString {
|
||||
f: formula_index,
|
||||
ei: Error::NIMPL,
|
||||
v: rich_text_inline.unwrap_or("".to_string()),
|
||||
s: cell_style,
|
||||
o,
|
||||
m,
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
@@ -796,7 +795,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
|
||||
// 18.3.1.4 c (Cell)
|
||||
// Child Elements:
|
||||
// * v: Cell value
|
||||
// * is: Rich Text Inline (not used in IronCalc)
|
||||
// * is: Rich Text Inline
|
||||
// * f: Formula
|
||||
// Attributes:
|
||||
// r: reference. A1 style
|
||||
@@ -820,6 +819,26 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
|
||||
None
|
||||
};
|
||||
|
||||
// <c r="A1" t="inlineStr">
|
||||
// <is>
|
||||
// <t>Hello, World!</t>
|
||||
// </is>
|
||||
// </c>
|
||||
let cell_rich_text_nodes: Vec<Node> =
|
||||
cell.children().filter(|n| n.has_tag_name("is")).collect();
|
||||
let cell_rich_text = if cell_rich_text_nodes.is_empty() {
|
||||
None
|
||||
} else {
|
||||
let texts: Vec<String> = cell_rich_text_nodes[0]
|
||||
.descendants()
|
||||
.filter(|n| n.has_tag_name("t"))
|
||||
.filter_map(|n| n.text())
|
||||
.map(|s| s.to_string())
|
||||
.collect();
|
||||
|
||||
Some(texts.join(""))
|
||||
};
|
||||
|
||||
let cell_metadata = cell.attribute("cm");
|
||||
|
||||
// type, the default type being "n" for number
|
||||
@@ -976,6 +995,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
|
||||
sheet_name,
|
||||
cell_ref,
|
||||
shared_strings,
|
||||
cell_rich_text,
|
||||
);
|
||||
data_row.insert(column, cell);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user