Hi, I have a code that generates XLS/CSV/XLSX file.
The code sends the file using ms.writeto(response.outputstream) to the client as a download dialog box.
I wanted to add a feature to download a compressed version of the file, so instead of sending the stream of the file, I zip it first and then send the stream of the zip file instead of the original XLS file.
I have been trying to do that but for some reason, using the code below, I get a ZIP file with an empty XLS file inside.
Please help me, I have been trying to solve it for few hours with no luck at all.
Response.ContentType = "application/x-zip-compressed"
Response.AddHeader("Content-Disposition", "attachment; filename=" + reportName + ".zip")
Dim ms As MemoryStream = New MemoryStream
If FileFormat = "CSV" Then
ElseIf FileFormat = "XLS" Then
ElseIf FileFormat = "XLSX" Then
Using zip As New ZipFile()
zip.CompressionLevel = Ionic.Zlib.CompressionLevel.BestCompression
Dim entry As ZipEntry = zip.AddEntry("report.xls", ms)
entry.SetEntryTimes(Now(), Now(), Now())