Note that there are some explanatory texts on larger screens.

plurals
  1. POread inserted data from excel spreadsheet while program execution POI, JAVA
    text
    copied!<p>I am creating an application that reads excel file into the programs and manipulates them. Before now, everything worked fine. But when I stareted implementing the GUI for my application it does not work anymore.</p> <p>here is the code:</p> <p>when the program launches it creates a gui with buttons and opens 2 new spreadsheets. I enter data in those spreadsheets and then press the button that calls crossReferenceButtonListener, however it fails to get the data out. error message below</p> <pre><code>public GUI () throws Exception{ this.setTitle("NYWM Cross Reference Application"); this.setSize(400,100); this.setVisible(true); this.setLocationRelativeTo(null); buttonHolder = new Panel (new BorderLayout()); this.add(buttonHolder); crossReference = new Button ("CrossReference"); generateHPD = new Button ("Generate HPD"); buttonHolder.add(crossReference, BorderLayout.NORTH); buttonHolder.add(generateHPD, BorderLayout.SOUTH); crossReference.addActionListener(new crossReferenceButtonListener()); generateHPD.addActionListener(new generateHPDButtonListener()); createExcelSheet (log,"C:/Log.xlsx", "Log"); createExcelSheet(sheet,"C:/Spreadsheet.xlsx", "Spreadsheet"); } private void createExcelSheet (XSSFWorkbook wb, String path, String fileName) throws Exception{ try{ FileOutputStream out = new FileOutputStream (path); wb = new XSSFWorkbook (); XSSFSheet sheet = wb.createSheet(fileName); wb.write(out); Process p = Runtime.getRuntime().exec( "rundll32 url.dll, FileProtocolHandler " + path); } catch (Exception e){ throw e; } } private class crossReferenceButtonListener implements ActionListener { public void actionPerformed (ActionEvent event){ try { ref = new CrossReference (log.getSheet("Log"), sheet.getSheet("Spreadsheet")); ref.CrossReference(); JOptionPane.showMessageDialog(null, "Cross Reference was successful!"); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } } </code></pre> <p>error message: to be more specific, it fails at this line </p> <pre><code> ref = new CrossReference (log.getSheet("Log"), sheet.getSheet("Spreadsheet")); </code></pre> <p>error:</p> <pre><code>at java.awt.EventDispatchThread.run(Unknown Source) java.lang.NullPointerException at nywm_crossReferenceApplication.GUI$crossReferenceButtonListener.actionPerformed(GUI.java:70) at java.awt.Button.processActionEvent(Unknown Source) at java.awt.Button.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload