umya-spreadsheet icon indicating copy to clipboard operation
umya-spreadsheet copied to clipboard

`get_hyperlink()` doesn't work in combination with `get_lazy_read_sheet_cells()`

Open 0chroma opened this issue 8 months ago • 3 comments

When getting cells lazily, hyperlinks don't seem to be read. For example, this works:

let book = umya_spreadsheet::reader::xlsx::read(path.clone())?;
let sheet = book.get_sheet(&0).unwrap();
let cells = sheet.get_collection_by_row(&2);
let links = cells
    .iter()
    .filter_map(|cell| {
        cell.get_hyperlink().map(|hl| hl.get_url().to_string())
    })
    .collect::<Vec<_>>();
dbg!(links);

But this does not:

let book = umya_spreadsheet::reader::xlsx::lazy_read(path.as_ref())?;
let sheet = book.get_lazy_read_sheet_cells(&0).unwrap();
let cells = sheet.get_collection_by_row(&2);
let links = cells
    .iter()
    .filter_map(|cell| {
        cell.get_hyperlink().map(|hl| hl.get_url().to_string())
    })
    .collect::<Vec<_>>();
dbg!(links);

0chroma avatar Jun 04 '25 05:06 0chroma

@0chroma When a file is read with lazy_read, most of the information including hyperlinks is not accessible because it has not yet been deserialized. Please execute read_sheet after lazy_read.

let book = umya_spreadsheet::reader::xlsx::lazy_read(path.clone())?;
book.read_sheet(0); // <- this
let sheet = book.get_sheet(&0).unwrap();
let cells = sheet.get_collection_by_row(&2);
let links = cells
    .iter()
    .filter_map(|cell| {
        cell.get_hyperlink().map(|hl| hl.get_url().to_string())
    })
    .collect::<Vec<_>>();
dbg!(links);

MathNya avatar Jun 09 '25 05:06 MathNya

hmm I feel like it would be better to raise an exception if I'm reading data that hasn't been deserialized yet, I spent a lot of time debugging in order to figure out why I wasn't getting anything back

0chroma avatar Jun 10 '25 12:06 0chroma

@0chroma Sorry. I apologize for the extra time and effort. As you indicated, we will modify the system to display error messages.

MathNya avatar Jun 11 '25 09:06 MathNya