tfussell / xlnt

:bar_chart: Cross-platform user-friendly xlsx library for C++11+
Other
1.47k stars 409 forks source link

What xlnt::workbook::save guarantees? #643

Closed kelbon closed 2 years ago

kelbon commented 2 years ago

What if file error and path was already used? Old file corrupted? Is exist a way to modify file and save it (without full rewrite?)

tfussell commented 2 years ago

xlnt always overwrites the existing file with the full content. It supports reading and writing to an array of bytes if you want to write your own logic.

kelbon commented 2 years ago

xlnt always overwrites the existing file with the full content. It supports reading and writing to an array of bytes if you want to write your own logic.

but is it exception/error safe? Can it break file while trying?

tfussell commented 2 years ago

but is it exception/error safe? Can it break file while trying?

There are several places where the function could throw. To be safe, I would recommend writing to a new file and then overwrite the old file with the new file atomically with an OS function like std::filesystem::rename.