brendan-duncan / archive

Dart library to encode and decode various archive and compression formats, such as Zip, Tar, GZip, ZLib, and BZip2.
MIT License
399 stars 139 forks source link

archive class to save as file(xlsx) did not work #247

Closed YancyHsu closed 2 months ago

YancyHsu commented 1 year ago

no error display, but when open the Excel file, it shows "File Corrupted"

not worked code:

final outputStream = OutputFileStream(xlsxFilePath);
var outputBytes = ZipEncoder().encode(_archive)!;
outputStream.writeBytes(outputBytes);
YancyHsu commented 1 year ago

but when i extract Archive to a folder first, then zip it, it works, the Excel file is OK. So i think something wrong with OutputFileStream, maybe i misuse it? Can somebody help?

worked code:

var outputFolder = 'output';
extractArchiveToDisk(_archive, outputFolder);
var dir = Directory(outputFolder);
var encoder = ZipFileEncoder();
encoder.zipDirectory(dir, filename: xlsxFilePath);
dir.deleteSync(recursive: true);
Tristl commented 1 year ago

Got similar problem Try with version 3.3.2, until that version it works for me