aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Write JTable to Excel file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Write JTable to Excel file" Watch "Write JTable to Excel file" New topic
Author

Write JTable to Excel file

Rus Corina
Ranch Hand

Joined: Jul 08, 2011
Posts: 90
Hello. I need to export a JTable to an excel file, but there is some formatting required. First of all, independent from the table, I need to write in a corner some data abou a company. Then , right before the table, I need to write a title, on the middle of the page. These information need to be written with a font different than the one used to write in the table: bold, a bit bigger and underlined. Then there comes the table. The table needs to appear with a table structure, meaning to have the borders that show that it is a table. Everything that I mentioned above needs to look like that when I set the excel file for printing. I don't know if what I want is very clear, i'll explain it again if necesary, but does anybody know if this can be done, and if so, what would be the best tool for it?

I found the jxl jar and an example on it, but it just exports the data as it is, and when i try to print the page, it doesn't show a table, just info written one under another, the info is not formatted, meaning i looks something like this:

DepartmeDaily Revenue
HousewarRs.1275.00
Pets Rs.125.00
Electronic Rs.2533.00
Menswear Rs.497.00

instead of looking like this:

Department Daily Revenue
Housewares Rs.1275.00
Pets Rs.125.00
Electronics Rs.2533.00
Menswear Rs.497.00

and having the table border, and column names specified explicitly (with different font)

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Write JTable to Excel file