Forum Stats

  • 3,767,936 Users
  • 2,252,732 Discussions
  • 7,874,386 Comments

Discussions

how to transfer JTable contents to an excel sheet

843807
843807 Member Posts: 46,582
edited Oct 17, 2002 10:02PM in Java Desktop Applications
hello everybody , iam new to this forum
i have the following problem
iam currently developing an Accounting package for
a small office , they want to send the reports generated
by my java program as Excel sheet e-mail attachments to their
head office . is it possible to get data from JTable in to
excel sheet. please kindly offer me a solution/source




Comments

  • 843807
    843807 Member Posts: 46,582
    Hi,

    the simples thing is to save ou table in a file with .txt or .xlt extension. The file must be a standard ASCII file in which the column separator is a TAB.

    regards
    andreas
  • mlk
    mlk Member Posts: 5,225
    or use POI, http://jakarta.apache.org/poi/index.html
  • 843807
    843807 Member Posts: 46,582
    You could always use JDBC. It just takes a little patience to get the connect string just right. But you can create worksheets by doing "Create Table" commands and then insert the data as you would a normal db table.
    A common usage is to create an XLS with a worksheet that will contain the data and then other worksheets that would have your reports or pivot tables. Then use the Java app to populate the data in the data sheet.
    JMH...
  • 843807
    843807 Member Posts: 46,582
    Here is a sample url string that I have used:
    String url = "jdbc:odbc:DRIVER={Microsoft Excel Driver (*.xls)};DBQ=c:\\temp\\Budget.xls;";
This discussion has been closed.