QtExcel / QXlsx

Excel file(*.xlsx) reader/writer library using Qt 5 or 6. Descendant of QtXlsxWriter.
https://qtexcel.github.io/QXlsx/
MIT License
1.17k stars 358 forks source link

How can I lock a file excel with a password? #5

Closed tarzan115 closed 6 years ago

tarzan115 commented 6 years ago

I don't want anyone else modifies my file so I want to lock a file with a password. How can I do that?

j2doll commented 6 years ago

QXlsx does not support encryption now. I am currently very busy 😭 and can not afford to develop that feature. It is a feature to set a password when you decompress legacy zip. (xlsx excel file is a zip file.) I plan to develop it in the future if I have time.

The following C++ projects are supported. It called xlnt. https://github.com/tfussell/xlnt xlnt uses cmake and C++11. It does not support Qt. If you know how to use cmake and C++11, you may use it! xlnt is good in Mac, Linux, Visual Studio. But it is sometimes buggy in MSYS or MinGW. (But if you bring up a bug issue, they will fix it. I did!) The following is an example of xlnt.

int main()
{
    xlnt::workbook wb;

    const auto password = std::string("secret");
    wb.load(path_helper::samplefile("encrypted.xlsx"), password); 
    wb.save("decrypted.xlsx");

    return 0;
}

I hope this helps. 😄

j2doll commented 6 years ago

Hi. I have created a project for easy use of xlnt in Qt. If you are interested in the project, please take a look.

:octocat: https://github.com/j2doll/Qxlnt

I am found that encrypting in xlsx is not an easy task. I have seen ECMA-376 and have found it to support a variety of encryption algorithms. (AES, etc.) So I created Qxlnt as a way to easily handle encrypted xlsx in Qt. I will try to apply it later on to QXlsx.

tarzan115 commented 6 years ago

that great. Qxlnt have all I need 😃 Thank you so much.

j2doll commented 6 years ago

Enjoy programming. 😸