Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java Excel

 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need some examples for reading an excel file and save it automaticallyin java?

I'm using jxl , but Idon't see any method save in jxl API.

Thanks
 
Meet Gaurav
Ranch Hand
Posts: 492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache POI is the best option.
 
Maneesh Godbole
Saloon Keeper
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the page Accessing File Formats in our FAQ pages.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meet Gaurav wrote:Apache POI is the best option.

I disagree; I prefer JExcelAPI (JXL) myself.

Anvi, check out Workbook.createWorkbook. These methods allow you to specify the file or output stream to write the workbook to. WritableWorkbook has methods write() and close() you can use for the actual writing and cleaning up.
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apache POI is the best option.
I disagree; I prefer JExcelAPI (JXL) myself.

Without any qualifications, neither of these statements is very convincing. Why do you think one is better than the other?

POI does have the advantage of handling XLSX in addition to XLS, and of having APIs very similar to HSSF/XSSF for other document formats (thus providing a head start if one knows HSSF/XSSF already). Of course, it's possible that neither of these matter in this particular case.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I last tried both, I found retrieving the cell formatting much easier in JExcelAPI. But that said, in most cases neither one is the best option; it is all a matter of opinion. And Anvi has already chosen for JExcelAPI, then who are we to say that he/she should switch to POI?
 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would I save the excel file using JEXCEL . I have used write but it writes only to the WritableSheet but it didn't save it?

Also does it supports charts and graphs?

Which source is best for graphs and charts?

thanks
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check out the link Maneesh posted? It has a section on "Writing Spreadsheets" which seems to be spot on.
 
anvi kon
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, It doesn't have a example which saves the excel file into another file.


 
Paul Clapham
Sheriff
Pie
Posts: 20750
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anvi kon wrote:Yes, It doesn't have a example which saves the excel file into another file.


That's true. It doesn't have an example which reads a spreadsheet from a file, modifies it, then saves it in another file. But as the tutorial itself observes, you can't write a tutorial which shows exact examples of everything somebody might want to do. It says:

The tutorial is by no means exhaustive, and if something is not described here, it does not mean that it cannot be done. The reader is encouraged to examine the API documentation and the sample code (particularly Write.java and ReadWrite.java) in order to gain a more complete understanding of the capabilities and limitations of the software.


So if it was me with this question, I would now be looking at the ReadWrite.java example to see what it did. And then I would be reading the API documentation of the Workbook class to look for possible solutions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic