Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Parsing Excel file fails with spsheet
Hey there, everyone. I'm working on a project that I would like to have file support for both ODs and Excel, and while I found a candidate in spsheet, it has had some problems.
Seeing as it has been dormant for so long, it might be understandable that you guys would wonder why I don't use calamine, and I have looked it into it, but file access is not as convenient, since I don't see a way to just grab the first sheet and the files I expect to have will only be one sheet.
Recently, I have created a fork of spsheet to resolve some of things, like Excel file reading and writing not working, and got it fixed, as well as updated the version of nom used to the 8.x version, but I'm having issues with parsing a spreadsheet.
The format of the spreadsheet is as follows:
Col1 | Col2 | Col3 | Col4 | Col5 | Col6 | Col7 | Col8 | Col9 | |
---|---|---|---|---|---|---|---|---|---|
id1 | a | b | c | d | e | f | g | h | i |
In this scenario, I'm grabbing data from the point of id1 to h on every row.
When I run the code to import an ODS file, it parses it as it should, but when I run the code to import it from an XLSX file, I get an error saying that it received an unexpected None at this point in the code:
let index = string_value.parse::<usize>().unwrap();
let val = shared_strings.get(index).unwrap();
Cell::str((*val).clone(), String::from(""))
However, when I changed it to the below, nothing would import at at all:
let index = string_value.parse::<usize>().unwrap();
if let Some(val) = shared_strings.get(index) {
Cell::str((*val).clone(), String::from(""))
} else {
Cell::str("", "")
}
Does anybody know how to deal with this?
1 post - 1 participant
🏷️ rust_feed