MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can I change the value of a cell from a opening book without closing it?

baiguoname opened this issue · comments

The work process: close the book -> delete the book -> run the code -> open the book, is too long for some small tasks. Can I just modify the existing book without closing it? (like xlwings in python)

hi baiguoname.

You can change value of a cell by following this procedure.

// file path
let path = std::path::Path::new("./tests/test_files/aaa_replace.xlsx");
// open the book
let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();
// change value
book.get_sheet_by_name_mut("Sheet1").unwrap().get_cell_mut("A1").set_value("TEST");
// save file
let _ = umya_spreadsheet::writer::xlsx::write(&book, path);

Yes, that is a wonderful way. But sometimes there may be a more convenient way to play data. For example, I have a data in Rust repl . I need to know the detail of the data, then I write the data to a excel, and open the excel to check the detail of it. And next, I modify the data and again check the detail of the data. I have to close the old excel, and run the program(saving data to excel), and open the file again. If I can save the data to excel without closing the file, then I don't have to redo opening and closing again and again.

@baiguoname
I finally understand your question.
Umya-spreadsheet cannot perform operations like xlwings.
This library is designed like pandas in python.