Skip to content

Commit ef6707c

Browse files
committed
Use 64-bit when necessary. Set sizes to 0 for Excel compatibility.
1 parent 1e4657a commit ef6707c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/excel/xlsx/zip_file.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void ZipFileWriter::AddDirectory(const string &dir_path) {
225225
mz_zip_file file_info = {};
226226
file_info.filename = dir_path.c_str();
227227
file_info.compression_method = MZ_COMPRESS_METHOD_STORE;
228-
file_info.zip64 = MZ_ZIP64_DISABLE; // not compatible with XLSX
228+
file_info.zip64 = MZ_ZIP64_AUTO; // only use 64-bit when necessary
229229

230230
mz_zip_writer_add_buffer(handle, nullptr, 0, &file_info);
231231
}
@@ -237,7 +237,13 @@ void ZipFileWriter::BeginFile(const string &file_path) {
237237
mz_zip_file file_info = {0};
238238
file_info.filename = file_path.c_str();
239239
file_info.compression_method = MZ_COMPRESS_METHOD_DEFLATE;
240-
file_info.zip64 = MZ_ZIP64_DISABLE; // not compatible with XLSX
240+
file_info.zip64 = MZ_ZIP64_AUTO; // only use 64-bit when necessary
241+
242+
// Set sizes to 0 to force use of data descriptor (Excel-compatible)
243+
file_info.uncompressed_size = 0;
244+
file_info.compressed_size = 0;
245+
file_info.flag |= MZ_ZIP_FLAG_DATA_DESCRIPTOR;
246+
241247
if (mz_zip_writer_entry_open(handle, &file_info) != MZ_OK) {
242248
throw IOException("Failed to open entry for writing");
243249
}

0 commit comments

Comments
 (0)