thscharler / spreadsheet-ods

Apache License 2.0
29 stars 6 forks source link

v0.21 regressions: set_col_width make the writer infinite #54

Closed mirsella closed 2 months ago

mirsella commented 3 months ago

hello

this code (the only relevant part is the set_col_width

    for (i, reel) in reels.into_iter().enumerate() {
        let i = i as u32 + 1;
        let url = &reel.url;
        let formula = format!(r#"=HYPERLINK("{url}";"url")"#);
        sh.set_formula(i, 0, formula);
        sh.set_col_width(0, spreadsheet_ods::Length::In(0.40));
        sh.set_value(i, 1, *reel.ratio.unwrap_or_default());
        sh.set_value(i, 2, &reel.account);
        sh.set_col_width(2, spreadsheet_ods::Length::In(1.));
        sh.set_value(i, 3, reel.like as u32);
        sh.set_value(i, 4, reel.comments as u32);
        sh.set_col_width(4, spreadsheet_ods::Length::In(0.7));
        sh.set_value(i, 5, reel.views.unwrap_or_default() as u32);
        sh.set_value(i, 6, reel.duration.as_secs().to_string());
        sh.set_col_width(6, spreadsheet_ods::Length::In(0.6));
        sh.set_value(i, 7, reel.paid_partnership);
        sh.set_col_width(7, spreadsheet_ods::Length::In(0.5));
        sh.set_value(i, 8, &reel.date.format("%d-%m-%Y %H:%M:%S").to_string());
        sh.set_col_width(8, spreadsheet_ods::Length::In(1.35));
        sh.set_value(i, 9, &reel.caption);
        sh.set_col_width(9, spreadsheet_ods::Length::In(15.));
    }

Works on < 0.21 works on >= 0.21 if i remove all the set_col_width. (it seems like only the last 3 works. If I put 4 or if it's not the max last 3 it break again)

the doesn't work is quite simple, write_ods* functions all hang and never finish (finish at a very long time with Zip error Large file option has not been set or simply no space left on device) because it writes continuously data, like a infinite loop. it's the function write_sheet in write.rs, but i don't know enough the code to go further. in any case, this is related to the change in 0.21.

thanks !

mirsella commented 3 months ago

i edited the title and post as the problem occur also on 0.21, but not before

thscharler commented 3 months ago

Hello! Yes that was a problem which I fixed in e08d7c09 .

Would like to publish a new release with it, but I'm still waiting for arturoc's change with color-rs. I'm already thinking about throwing out that pub use for good.

thscharler commented 3 months ago

I published 0.22.3 just now. This should work for you.

mirsella commented 2 months ago

Hey, it appears to still not be resolved

the test added in https://github.com/thscharler/spreadsheet-ods/commit/fd5aebeaa037846253fc9bf898ff02efa2628a8f don't show it because there isn't enough data (my bad as i didn't specify the data when opening this issue)

i'll work on a minimal reproduction code / improving the test case soon. for now it seems to be happening when there is multiple "reels", more than one in the for loop.

thscharler commented 2 months ago

It seems setting the width multiple times did the trick. Lost the span somewhere, and advancing by 0 doesn't do much.

If you would confirm this, then I will do a patch-release.

mirsella commented 2 months ago

It works !

Thanks, have a great day