aspose file tools*
The moose likes Other Open Source Projects and the fly likes Basic Java API for creating Excel? 2 DIM table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Basic Java API for creating Excel? 2 DIM table" Watch "Basic Java API for creating Excel? 2 DIM table" New topic
Author

Basic Java API for creating Excel? 2 DIM table

H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
Hi,

What is the basic JAVA API for creating Excel? I need to create a simple 2 DIM table as below.

Item | Color | Quantity

XZY | RED | 100


1M Thanks.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
The easiest would be to use CSV - the http://www.coderanch.com/how-to/java/AccessingFileFormats page lists several libraries for that.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
(Used Apache POI)

For now the Name of header column is hard-coded as below. So is the data using the getters as below:



Question:

Is there a way where I can externalize the header name like Items, Dimension, Price in a file (properties)
so that within the JAVA source code will do the getter automatically?

By that I mean, if I need to add 2 extra header column, then all I need to add to the external file
and there is no need to change the JAVA source code.

OR is there any better way of doing what I did?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
I don't see why that should be a problem.
H Paul
Ranch Hand

Joined: Jul 26, 2011
Posts: 471
    
    4
It's not really a problem. It's just "static" in the sense
if I need some extra column/field, I need to modify the JAVA source code



I just to make the column/fields configured in an external file so that it's more "dynamic" so that JAVA read these fields and dynamically generate
Excel Header column and data column from corresponding getters.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42929
    
  68
That's not what I meant. I meant that I don't see a problem with reading a properties file, and based on the information in it, generate a varaiable number of columns in the spreadsheet.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Basic Java API for creating Excel? 2 DIM table