• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Generate Excel report in java

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The excel report is displayed as junk data as shown below irrespective of the api i am using in the unix environment. But the same code is working fine in the windows env. i have tried with POI and JXL APIs.

I guess i need to do some additional config for content type. Pls help me asap.

������>�� ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������� ������\pJava Excel API v2.6 B�a=���=h\:�#8X@�"��1���Arial1���Arial1���Arial1���Arial��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � ��� � � � �+�� � �)�� � �,�� � �*�� � � �� � ������������������`�U* Shell Cards�,� #.Detail Card Information Display Card NumberAccountNameCard NoMedia Vehicle No Driver NameMax Qty Daily Limit Weekly Limit Monthly Limit Txn per DaySuperRegularDieselKeroseneLubes Card ExpiryCurrent Status Vehicle No.2 Vehicle No.3 Vehicle No.4 Vehicle No.5 Vehicle No.6 Vehicle No.7 Vehicle No.8 Vehicle No.9 Vehicle No.10Site-Region Restriction Site-Region 1 Site-Region 2 Site-Region 3 Site-Region 4 Site-Region 5 Site-Region 6 Site-Region 7 Site-Region 8 Site-Region 9Site-Region 107002481 81180 1182481180 TARGET LLCF Magnetic 5407 DS 700.0NO Aug-2004 Card Expired new card issued 7002481 81180 118325408 DS607002481 81180 118405553 DS7002481 81180 11857406 MA50Feb-20057002481 81180 118658475 AS40Jun-20057077481 81180 11875S3630 SSFeb-2006 new card not issued 7002481 81180 118815024 AKL.V.7380Mar-20067027481 81180 11896G8938 SSMR.YOUSUF SHAMMAS0Apr-20067027481 81180 119044435 M TARGET L.L.C.May-20067002481 81180 11915 Smart Card1644 BKL.V.7680.0560.02480.02.0Jan-2009"Active - Delivered on 27/Feb/2005N7002481 81180 119235093 BKL.V- 7560.0420.01860.07002481 81180 119495016 AWOct-2009"Active - Delivered on 03/Oct/20057002481 81180 119561841 MD50.0Mar-2010"Active - Delivered on 11/Mar/20067077481 81180 11966OPEN7002481 81180 11972773 MDC-26"Active - Delivered on 21/Mar/20067002481 81180 11980L.V-82100.07002481 81180 119984136 WKL.V-85"Active - Delivered on 02/Apr/20067002481 81180 120042656 HWL.V-77100Apr-2010"Active - Delivered on 12/Apr/20067002481 81180 217329977 AB SUBARU S/W7077481 81180 21767EMERGENCY CARD7002481 81180 2182370.0490.02170.0Sep-2008"Active - Delivered on 28/Aug/20047002481 81180 218317002481 81180 218497002481 81180 21856Feb-2009 Terminated7002481 81180 2186440.0Jun-2009"Active - Delivered on 25/Jun/20057077481 81180 21874120.0Feb-2010"Active - Delivered on 27/Feb/20067002481 81180 218807027481 81180 21895"Active - Delivered on 08/May/20067027481 81180 21903May-2010"Active - Delivered on 28/May/20067077481 81180 31550Apr-20057077481 81180 315687077481 81180 31592"Damaged on 17/Mar/2004 - reissued7077481 81180 316187027481 81180 31654Oct-20057002481 81180 316818480 ASTARGET CO.L.L.C7027481 81180 317202563 ABBMWMay-20057002481 81180 317317077481 81180 317667002481 81180 317803868 DK7002481 81180 406415580 AK7002481 81180 41284 17027 MCTMITSUBISHI P/U"Damaged on 19/Jul/2003 - reissued7002481 81180 413429297 AB7002481 81180 413758569 HKM.A.N.WATER TANKER7002481 81180 41409"Damaged on 31/May/2003 - reissued7002481 81180 41417274 HKL.V.63Sep-20057002481 81180 415167480 AK2007077481 81180 41559Apr-2009"Active - Delivered on 15/May/20057077481 81180 41567"Active - Delivered on 25/Apr/20057077481 81180 415917077481 81180 416177027481 81180 41638MR.HANI JUMAN ASHOUR RAJAB7002481 81180 416494722 MKNov-20057002481 81180 41664713 HM"Blocked on 25/Aug/2004 - reissued 7002481 81180 416807002481 81180 506407002481 81180 507079089 BK HINO TIPPER7002481 81180 5072395 HKL.V.067002481 81180 50749273 HK7002481 81180 507569094 BKMITSUBISHI ROSA BUS7002481 81180 510104491 RKL.V.557002481 81180 510364755 WKL.V.527002481 81180 512267860 HKSCANIA PRIME MOVER7002481 81180 51283840 RKJul-20057002481 81180 513661068Jan-20067002481 81180 51374May-2009"Active - Delivered on 10/Oct/20057002481 81180 513905579 AK907002481 81180 51408 Suspended7002481 81180 51416Sep-20097002481 81180 51424270 HKL.V.647002481 81180 514322874 DKL.V.657002481 81180 514403867 DK7077481 81180 515907077481 81180 516087002481 81180 51648Nov-2009"Active - Delivered on 18/Feb/20067002481 81180 51663Aug-20087002481 81180 516973400 HK ASHWAK LILAND200.01400.06200.07002481 81180 517132651 MKHYUNDAI7002481 81180 607067002481 81180 607487002481 81180 610357002481 81180 6122<$5"Active - Delivered on 28/May/20057002481 81180 61282Jul-20097002481 81180 61365350.01550.0Jan-20107002481 81180 6139990.07002481 81180 614317002481 81180 614497077481 81180 616077002481 81180 61712"Active - Delivered on 22/Sep/20057002481 81180 709943377Dec-2004"Blocked on 19/Jul/2003 - reissued 7002481 81180 809937002481 81180 90992"Active - Delivered on 30/Jul/2005�*� Owx �� 2Aip���<e���%M|���(P[�x �� .G o� �� � (A i� �� � <Q y� �� . VU }�
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's not clear what you mean exactly.

Excel files (with extension .XLS) are binary files that can only be opened by programs that understand the format, such as Microsoft Excel or OpenOffice Calc.

If you just display the contents of an XLS file in a shell (what you seem to be doing?) then you will ofcourse see garbage. It's not a plain text file.
 
Senthilkumar Adaickalam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Young,

I need to display the summary of transactions in the excel sheet. I have tried with both POI and JXL to complete this functionality. Its working fine in my dev machine(Windows). But when i moved to the prod env (unix machine), its dispayed the data as shown below. My code goes as below:

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition",
"attachment; filename=sampleName.xls");

//JXL
WritableWorkbook w = Workbook.createWorkbook(response.getOutputStream());
WritableSheet s = w.createSheet("Cards", 0);
s.addCell(new Label(0, 0, "columnValue"));
w.write();
w.close();

//POI
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Cards");
HSSFRow row = sheet.createRow((short)0);
row.createCell((short)0).setCellValue("columnValue");
FileOutputStream fileOut = new FileOutputStream("cards.xls");
wb.write(fileOut);
fileOut.close();


I am creating the workbook by reading the data from the .csv file which is stored on the weblogic5.1 server.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So the file that is generated is valid in the sense that Excel can open and display it on Windows. That's good. So: Which program are you using on Unix that can't display the file? As Jesper points out, XLS files are binary files - you can't display them on the command line.
 
Don't destroy the earth! That's where I keep all my stuff! Including this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic