MathNya / umya-spreadsheet

A pure rust library for reading and writing spreadsheet files
MIT License
238 stars 41 forks source link

The set_workbook_password method seems to be invalid #176

Closed shijunti19 closed 4 months ago

shijunti19 commented 4 months ago

The set_workbook_password method seems to be invalid, and the generated document remains unchanged book_lock.xlsx image image image

office2019

If the settings are normal, it should be like this: image

MathNya commented 4 months ago

@shijunti19 Using write_with_password will do what you want.

    let path = std::path::Path::new("./tests/test_files/aaa.xlsx");
    let mut book = umya_spreadsheet::reader::xlsx::read(path).unwrap();
    let path = std::path::Path::new("./tests/result_files/bbb_password.xlsx");
    let _ = umya_spreadsheet::writer::xlsx::write_with_password(&book, path, "password");

set_workbook_password corresponds to the function shown in the following figure in Excel. image