File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -225,7 +225,7 @@ void ZipFileWriter::AddDirectory(const string &dir_path) {
225
225
mz_zip_file file_info = {};
226
226
file_info.filename = dir_path.c_str ();
227
227
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
229
229
230
230
mz_zip_writer_add_buffer (handle, nullptr , 0 , &file_info);
231
231
}
@@ -237,7 +237,13 @@ void ZipFileWriter::BeginFile(const string &file_path) {
237
237
mz_zip_file file_info = {0 };
238
238
file_info.filename = file_path.c_str ();
239
239
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
+
241
247
if (mz_zip_writer_entry_open (handle, &file_info) != MZ_OK) {
242
248
throw IOException (" Failed to open entry for writing" );
243
249
}
You can’t perform that action at this time.
0 commit comments