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
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply 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: 35443
    
    9
See java.util.zip.GZIPOutputStream.


Android appsImageJ pluginsJava web charts
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: 10043
    
    6

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?"

Never ascribe to malice that which can be adequately explained by stupidity.
 
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
zip file does not contain any text file ??
ZipOutputStream
Compress .zip using Java
Zip Directory Recursively
Creation of .zip file???