JTable-How to save in file

Hi all,

I am developing an application using JTable in swing.I want to save all the records of that JTABLE in excel and pdf file.Please help me with code.Thanks

[173 byte] By [nivaz_sharmaa] at [2007-11-27 10:55:08]
# 1

There are several ways you can do this but I would start by creating my own table model (extend AbstractTableModel) that includes some sort of save method. That way the model has easy access to all of the data and it can write it out as needed.

For Excel, you may want to save the data as tab- or comma-delimited format. Excel easily imports this data as well as a lot of other tools. This way you are not tied to Excel specifically.

For creating PDF you can use a library like iText to create the file manually or make calls to the OpenOffice API to do it for you.

markwagonera at 2007-7-29 11:54:26 > top of Java-index,Desktop,Core GUI APIs...