MortalreminderPT / edit-xlsx

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

Coming back here, it now panics at the `Workbook::new()` giving me this traceback: #5

Closed MortalreminderPT closed 3 months ago

MortalreminderPT commented 3 months ago
          Coming back here, it now panics at the `Workbook::new()` giving me this traceback:
thread 'main' panicked at C:\Users\Windows\.cargo\registry\src\index.crates.io-6f17d22bba15001f\edit-xlsx-0.3.6\src\api\workbook.rs:52:59:
called `Result::unwrap()` on an `Err` value: ZipError(Io(Os { code: 3, kind: NotFound, message: "Impossibile trovare il percorso specificato." }))
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\std\src\panicking.rs:645
   1: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\core\src\panicking.rs:72
   2: core::result::unwrap_failed
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library\core\src\result.rs:1653
   3: enum2$<core::result::Result<edit_xlsx::api::workbook::Workbook,enum2$<edit_xlsx::result::WorkbookError> > >::unwrap<edit_xlsx::api::workbook::Workbook,enum2$<edit_xlsx::result::WorkbookError> >
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112\library\core\src\result.rs:1077
   4: edit_xlsx::api::workbook::Workbook::new
             at C:\Users\Windows\.cargo\registry\src\index.crates.io-6f17d22bba15001f\edit-xlsx-0.3.6\src\api\workbook.rs:52
   5: vimdb::utils::registro::crea_registro
             at .\src\utils\registro.rs:6
   6: vimdb::inserisci_anno
             at .\src\main.rs:67
   7: vimdb::aggiungi_email
             at .\src\main.rs:58
   8: vimdb::main
             at .\src\main.rs:21
   9: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112\library\core\src\ops\function.rs:250
  10: core::hint::black_box
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112\library\core\src\hint.rs:286
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\vimdb.exe` (exit code: 101)

Looking at:

impl Workbook {
    pub fn new() -> Workbook {
        let mut wb = Self::from_path("resource/new.xlsx").unwrap();
        wb.file_path = String::from("./new.xlsx");
        wb
    }

Seems like the workbook tries to load a resources/new.xlsx but since there is no such files it panics saying that no such file exists. Hope this help fixing this, thanks for your hard work 😃. (Btw, the same code worked fine before the update and I am using Windows 10, you probably needs those informations too.)

EDIT: The Workbook::from_path(path) works fine, only the ::new() doesn't. And changing the font works too. Thank you for your work 👍.

Originally posted by @Antonio225t in https://github.com/MortalreminderPT/edit-xlsx/issues/3#issuecomment-2040096407

MortalreminderPT commented 3 months ago

I may have fixed this bug on another computer but forgot to PUSH it, I'll fix this tomorrow 😶

MortalreminderPT commented 3 months ago

I fixed this bug in version 0.3.7, and I think it will not happen in future versions.