1

How can I view a sheet from .ods file in JTable? I'm using odftoolkit simple api and that's how I open the file

      String filepath;
      if (openfile.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
        filepath = openfile.getSelectedFile().getAbsolutePath();
        try {
            doc = SpreadsheetDocument.loadDocument(filepath);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null,
                    Locale.getString("fileError.message"),
                    Locale.getString("fileError.title"),
                    JOptionPane.ERROR_MESSAGE);
            return;
        }

At this time I get every row with doc.getTableList().get(0).getRowList(). How could I turn every row into array?

mKorbel
  • 109,107
  • 18
  • 130
  • 305
  • What type does `doc.getTableList().get(0).getRowList()` return? I'm pretty sure it provides some method that will let you make an array of it. – MightyPork Aug 05 '13 at 19:54
  • Is there Javadoc for their API? Have you tried reading it? – Bill Aug 05 '13 at 19:55
  • `getRowList()` returns a list of `Row` and I found no useful method in `Row` class. Maybe I'm stupid, maybe not ;D Sure there is. No, I've just googled a little bit. – LivingSilver94 Aug 05 '13 at 19:57
  • 2
    read Oracle tutorial, How to use Tables part Creating a Table Model – mKorbel Aug 05 '13 at 20:28

1 Answers1

2

How could I turn every row into array?

Don't. Instead, build a TableModel that implements the essential methods, as shown here, using the methods provided by the ODF API.

@Override
public String getColumnName(int col) {…}

@Override
public int getColumnCount() {…}

@Override
public int getRowCount() {…}

@Override
public Object getValueAt(int row, int col) {…}
Community
  • 1
  • 1
trashgod
  • 200,320
  • 28
  • 229
  • 974