I am trying to find a class that uses POI to create a
Swing component to display/edit an Excel spreadsheet. I
tried using the contributed class SViewerPanel in the
following class:

package poitest;

import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.hssf.contrib.view.*;
import java.io.*;
import javax.swing.*;

public class Test {
  public static void main(String[] args) {
    FileInputStream fin = null;
    HSSFWorkbook wb = null;
    try {
     fin = new FileInputStream("Book.xls");
    }
    catch (FileNotFoundException ex) {
      ex.printStackTrace();
    }
    try {
      wb = new HSSFWorkbook(fin);
    }
    catch (IOException ex1) {
      ex1.printStackTrace();
    }
    SViewerPanel panel = new SViewerPanel(wb,true);
    JFrame frame = new JFrame();
    frame.getContentPane().add(panel);
    frame.setVisible(true);
  }
}

I get the following exception:

java.lang.NullPointerException
 at
org.apache.poi.hssf.contrib.view.SVRowHeader$RowHeaderR
enderer.getListCellRendererComponent(SVRowHeader.java:1
11)
 at
javax.swing.plaf.basic.BasicListUI.updateLayoutState(Ba
sicListUI.java:1147)
 at
javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutSta
te(BasicListUI.java:1097)
 at
javax.swing.plaf.basic.BasicListUI.getPreferredSize(Bas
icListUI.java:280)
 at
javax.swing.JComponent.getPreferredSize(JComponent.java
:1272)
 at
javax.swing.JList.getPreferredScrollableViewportSize(JL
ist.java:1910)
 at
javax.swing.ViewportLayout.preferredLayoutSize(Viewport
Layout.java:72)
 at
java.awt.Container.preferredSize(Container.java:1175)
 at
java.awt.Container.getPreferredSize(Container.java:1159
)
 at
javax.swing.JComponent.getPreferredSize(JComponent.java
:1274)
 at
javax.swing.ScrollPaneLayout.layoutContainer(ScrollPane
Layout.java:717)
 at java.awt.Container.layout(Container.java:1017)
 at java.awt.Container.doLayout(Container.java:1007)
 at
java.awt.Container.validateTree(Container.java:1089)
 at
java.awt.Container.validateTree(Container.java:1096)
 at
java.awt.Container.validateTree(Container.java:1096)
 at
java.awt.Container.validateTree(Container.java:1096)
 at
java.awt.Container.validateTree(Container.java:1096)
 at
java.awt.Container.validateTree(Container.java:1096)
 at
java.awt.Container.validateTree(Container.java:1096)
 at java.awt.Container.validate(Container.java:1064)
 at java.awt.Window.show(Window.java:450)
 at java.awt.Component.show(Component.java:1134)
 at java.awt.Component.setVisible(Component.java:1089)
 at poitest.Test.main(Test.java:37)

I can't figure out what I have done wrong. I am using
the latest dev release of Poi (2.0 pre 3).

If this class does not work, does anyone know of a
Swing visual component for viewing Excel files in a
Java app? thanks in advance for any help.

Gregg





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to