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

Basic Java API for creating Excel? 2 DIM table

 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see why that should be a problem.
 
H Paul
Ranch Hand
Posts: 471
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic