• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Saving a JTable

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anybody tell me how i can save a JTable in a format that can be read easily by MS Excel?
thanks
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The CSV format is a simple format that is readable by Excel... it stands for Comma Seperated Values, and that's basically all it is... it's just text with each row on a separate line and each column separated by commas.
 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do i have to save the file with a specific file extension other than .txt?
 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm pretty sure if the file name ends in .csv excel will automatically recognize it. if not, open up excel and click on the menu Data > Get External Data > Import Text File. from there, follow the steps in the wizard for rules on how to import the data.
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked at poi?
Jakarta Poi
I had to do something similar to what you're asking. Poi has an excel table represented as a high level class (you can modify cells, rows etc. easily without worrying about the low-level event model). All I did was extend the HSSFWorbook class (it represents a workbook). You could make the extended workbook take a jtable as an argument, populate the first row with the column headings (or whatever), and the other rows with the row data. Or extend the sheet model and add the sheets to a programtically created or read workbook.
Check it out, I've found Poi extrodinarily useful in several circumstances.
Michael Crutcher
 
If we don't do the shopping, we won't have anything for dinner. And I've invited this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic