• Post Reply Bookmark Topic Watch Topic
  • New Topic

trying to get Xlsm file into a jcombobox

 
Edward Siedlecki
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

I hope I have my code in an appropriate format for you.

I have posted a class ReadExcelDemo and I have this working correctly and can println and get my desired outcome. Where I am having issues is with taking that data and filling a JComboBox drop down menu which is the last line of code where I am getting the error Array Dimension missing. I am just trying to understand what I am doing wrong.



This is located in the GUI class.
selectProduct.setModel((new ReadExcelDemo.Castings[]).toString());// This is another class where I am trying to fill a Jcombobox
 
Campbell Ritchie
Marshal
Posts: 52581
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

I have corrected your code tags (thank you for using them) and got rid of the long line and excess blank lines.
I don't know about POI, but even before the xlsm problem, I can see two other serious problems:
  • 1: You are not closing a reader; there is a risk the file will be recorded as in use for ever.
  • 2: There is a risk of returning null from that method; you should avoid nulls like the plague. Return a 0‑length array instead.
  • I suggest, as a first step, you print out the contents of the xlsm file as you read it (about line 31), then you can confirm you are reading anything at all.
     
    Edward Siedlecki
    Greenhorn
    Posts: 2
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Thanks for the insight. in my attempt to post a snippet of code I somehow cut the close file command.

    I did figure out my issue. In my code selectProduct.setModel((new ReadExcelDemo.Castings[]).toString());// This is another class where I am trying to fill a Jcombobox. it had to be coded
    selectProduct.setModel(new DefaultComboBoxModel(ReadExcelDemo.Castings[]);
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!