Aditya Gandhi
Aditya Gandhi

Reputation: 21

Java Application to save form data into Excel sheet

How can I take input of user into a FORM in JAVA swing frame and save the user content into a MS Excel Sheet. Can i do that? Please suggest me I want to develop such application.

Upvotes: 0

Views: 2244

Answers (3)

nihar
nihar

Reputation: 66

@Aditya: First I would create a class that would consist of data that would be stored in excel file.

For example lets say you want to store student data(name, address, email) in to the file. Create a class students with above mentioned attributes. You can than create an object of the class and pass it to the form/frame.

Once the user enters all the data you can set the object properties with the form data. In this way you will have all the data and than all you need to do is save that information in excel file.

For saving the data you can use JExcelAPI. Kindly follow the instructions on http://www.javaworld.com/article/2074940/learn-java/java-app-dev-reading-and-writing-excel-spreadsheets.html.

Upvotes: 1

Pritam Banerjee
Pritam Banerjee

Reputation: 18923

There are lot of libraries which can help you with that :

  1. Apache POI
  2. docx4j

Both of them are quite uesful. For excel POI would be my personal choice.

Upvotes: 1

erik-sn
erik-sn

Reputation: 2600

I'm not too familiar with swing, but generally speaking you would bind an event to the frame that "submits". You would save the fields to variables.

Then you can use a library such as Apache POI to take your variables and write them to an excel spreadsheet. XLS, XLSX, XLSXM are all supported. You can look at the busy developers guide to get some good examples on how to read/write/create spreadsheets.

Upvotes: 0

Related Questions