MortalreminderPT / edit-xlsx

A quick and easy-to-use Rust library for Excel file editing.
https://crates.io/crates/edit-xlsx
25 stars 4 forks source link

max_column and max_row not working as expected with a Gridly export file #26

Open Yuubari opened 2 months ago

Yuubari commented 2 months ago

edit-xlsx version: 0.4.5 rustc version: 1.80.1 (stable), Windows 11 64-bit

When opening an xlsx spreadsheet exported from Gridly WorkSheet.max_row() and WorkSheet.max_column() return zeroes. read_cell() returns Err for just about everything.

Furthermore, if I remove the filter from the 5th row and save the file, sheet dimensions are suddenly determined correctly, but the cells are not read as expected: some cells return Err(RowError(CellError(CellNotFound))); in those that do not, text is Some(""), font is Calibri when it is Open Sans in the sheet, and so on.

I use the following code (trimmed down):

    let Ok(sheet) = book.get_worksheet(1).unwrap();
    let maxrow = sheet.max_row();
    let maxcol = sheet.max_column();
    // this results in 0, 0
    eprintln!("Sheet dimensions: {} columns, {} rows.", maxcol, maxrow);
    // skipped

    // most entries here contain Err; some have Ok but with empty text values
    let cellrange: Vec<WorkSheetResult<Cell<String>>> = (1..=44l) // maxcol replaced with 44 for testing purposes
        .map(|c| sheet.read_cell((row_start, c)))
        .collect();

Please find attached a sample Gridly export file. gridly.xlsx

MortalreminderPT commented 2 months ago

I'm sorry that I didn't maintain this project for a long time due to personal reasons😿, maybe in a while I'll have the energy to continue and fix this problem!

MortalreminderPT commented 3 weeks ago

This was caused by not setting a default value in AutoFilter for one of the fields, I think it should work now, if there are still problems, I hope you can leave a comment!😊