comments in original excel file are lost
Hi,
I found a new issue when opening and saving an excel file with umya-spreadsheet. Existing comments are deleted. Consider attached excel file with a comment in cell B2.
When using following script:
use umya_spreadsheet::{reader, writer};
fn main() {
// path
let path = "test.xlsx";
// 1. open excel file
let mut book = match reader::xlsx::read(path) {
Ok(b) => b,
Err(e) => {
eprintln!("Errore durante la lettura: {}", e);
return;
}
};
// 2. take sheet
let sheet = book.get_sheet_mut(&0).expect("Foglio non trovato");
// 3. Write "test" in B7
sheet.get_cell_mut("B7").set_value("test");
// 4. Save file
if let Err(e) = writer::xlsx::write(&book, path) {
eprintln!("Errore durante il salvataggio: {}", e);
} else {
println!("File salvato correttamente.");
}
}
The new resulting excel file will not have comment in B2 anymore.
As a work around I suspect you can save the comment before and set it after. I don't know much about the structure and if it's necessary to overwrite. Just a quick check gave me that ideas a workaround and mentioned it in case it helpful https://docs.rs/umya-spreadsheet/latest/umya_spreadsheet/structs/struct.Comment.html
Yes but working with big files with many comments will be complicated. It would be great if this could be fixed directly in umya 🙂
@ROMA96x Thank you for contacting us. We will investigate the cause.
@ROMA96x Fixed a bug. Please get the latest version.
Hi @MathNya, I updated to version umya-spreadsheet = "2.3.2" but I still see the issue.
Best regards, Marco