0

I've been having some issues with trying to populate a JTable with an excel spreadsheet. I'm attempting to create a database with information storing participant details, so I'm collecting their information through a Google Form and exporting the results into an Excel spreadsheet. After that, I want to get that excel spreadsheet into a JTable.

Everything I've tried either doesn't work, I don't truly understand what to do or all the sources on the topic are for NetBeans, while I'm using eclipse.

I need to complete this assessment for Monday (it's Saturday right now) and could really use some help!

l205
  • 1
  • 1
  • What approach have you tried so far for parsing the Excel file in Java and generate a JTable from it? Your problem has 2 subproblems: reading Excel in Java: https://stackoverflow.com/search?q=how+to+read+%5Bexcel%5D+file+%5Bjava%5D using jtable which is explained well in the Java Swing Tuorials https://docs.oracle.com/javase/tutorial/uiswing/components/table.html – squiddle Feb 23 '19 at 19:54
  • Thankfully, I've been able to figure out how to import an excel sheet into my JTable. But now I'm stuck on being able to add values from textFields in one frame into a JTable in another frame. Here's my code for the specific button doing the function: – l205 Feb 25 '19 at 04:57
  • public void actionPerformed(ActionEvent e) { DefaultTableModel model = new DefaultTableModel(); List list = new ArrayList(); List list1 = new ArrayList(); list.add(ParticipantDetails.ID_txtbox.getText()); .. (there's more with string) list1.add(ParticipantDetails.Age_combobox.getSelectedItem()); ... theres more with object model.addRow(list.toArray()); model.addRow(list1.toArray()); table.setModel(model); – l205 Feb 25 '19 at 05:00
  • @squiddle can you advise me on how to solve this problem? I basically want to get the textfields from one frame to insert and add a row into the JTable. I would also appreciate some help for delete function! – l205 Feb 25 '19 at 05:01
  • please create a new question here on StackOverflow for your new problem. That increases the chance of getting a helpful answer a lot. Also, any posted code looks much better and is easier to read than having it crammed in the comment field. regarding your question i can only point you to this question which seems to answer your question: https://stackoverflow.com/questions/3549206/how-to-add-row-in-jtable – squiddle Feb 26 '19 at 10:45

0 Answers0