aspose file tools*
The moose likes Java in General and the fly likes Converting Excel spread sheet generated at runtime to a zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Converting Excel spread sheet generated at runtime to a zip file" Watch "Converting Excel spread sheet generated at runtime to a zip file" New topic
Author

Converting Excel spread sheet generated at runtime to a zip file

Vishal Nadikudi
Greenhorn

Joined: Feb 09, 2010
Posts: 3
Hi All,

I have a problem in on of our applications, we are creating a HTML file that happens to be readable by Excel and now I have to compress the same to a zip file, below is the source code.

try {

DokumentSession dokumentSession = null;
byte[] resultBytes = null;
try {
dokumentSession = (DokumentSession) IPAContextHelper.getIPAContext().lookup(DokumentSession.class.getName());
} catch (NamingException e) {
LocalSystem.logError(e.getMessage());
e.printStackTrace();
}

// result bytes which gets the tagged html formatted data

resultBytes = dokumentSession.getXlsZuAuftrag(ts);
if (resultBytes != null && resultBytes.length > 0) {
// Wir lassen das XLS anzeigen
response.setContentType("application/vnd.ms-excel");
// byte Array wird in ein OutputStream geschrieben
ServletOutputStream out = response.getOutputStream();
out.write(resultBytes);
out.flush();
out.close();
}

Is there any way I can generate a zip out of this file, as the documents run huge, that is why we are planning to compress the same and give it to the user.


Vishal
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
See java.util.zip.GZIPOutputStream.


Ping & DNS - updated with new look and Ping home screen widget
Vishal Nadikudi
Greenhorn

Joined: Feb 09, 2010
Posts: 3
Ulf Dittmer wrote:See java.util.zip.GZIPOutputStream.


Hi,

Thanks for posting the api details, I already had a look at ZipOutputStream too, is it possible for you to provide me any small sample code which I can check for. Another information is, we are trying to do this change as the excel sheets generated are coming as too huge(> 50 MB) so if we can compress(zip) the file and give it back, it would possible to reduce the size of the file and also which could increase the portability.

Any help would be appreciated
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10916
    
  12

Vishal Nadikudi wrote:is it possible for you to provide me any small sample code

That's not how we generally do things here. We strive to help you learn to do it yourself. Why don't you give it a try, and then if you have problems come back here. You can say "I tried this, expected that, but got something else. Any tips on where I went wrong?"

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting Excel spread sheet generated at runtime to a zip file
 
Similar Threads
ZipOutputStream
Creation of .zip file???
Zip Directory Recursively
Compress .zip using Java
zip file does not contain any text file ??