0

Problem with loading excel data into JTable.

All I was able to find was about creating JTable from 2 dimensional array for rows and another single dimensional array for headers ...already filled with data in source code. Or way to do it for xls, not xlsx.

I can access rows and cells through for loop and via Apache POI and print them into console but I can not figure out how to add them into JTable.

When you take data from SQL, there is something like table.setModel(DbUtils.resultSetToTableModel(... with excel, I have not found anything like that, I have not found more less anything.

Any advice?

camickr
  • 321,443
  • 19
  • 166
  • 288
  • Show us some code. What have you tried so far? Why didn't it work? https://stackoverflow.com/help/how-to-ask – fstam Dec 20 '20 at 20:57
  • 3
    *I can access rows and cells through for loop and via Apache POI* Read the data yourself into a Vector and add the Vector to the TableModel. See: https://stackoverflow.com/questions/55627828/how-to-get-a-defaulttablemodel-objects-data-into-a-subclass-of-defaulttablemode/55635012#55635012 for the basic logic of this approach. – camickr Dec 20 '20 at 22:02
  • You can look at https://github.com/japplis/joeffice which is an open source office, the spreadsheet reads data from Apache POI and renders it in a JTable. Disclamer: I'm the author. – Anthony Dec 21 '20 at 11:07

0 Answers0