Jump to content

Exporting / Saving to xls from JasperViewer


magicrat

Recommended Posts

Hi everyone.

I'm using iReport 3.5.3. I need my report to be saved to xls but when I do that from the JasperViewer, I get the following exception:

 Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFCellStyle
  ...
 Caused by: java.lang.ClassNotFoundException: org.apache.poi.hssf.usermodel.HSSFCellStyle
  ...

I haven't written any export code, I just diplay the JasperViewer with the report on the screen. The user then may want to print it or save it to XLS. The print works perfectly, but when I test the "save" from the viewer toolbar I get the above exception. And the same happens if I save to pdf (and to all formats I guess). However, when doing it from within iReports, it works prefectly well.

I guess I need to include some JAR in the netbeans library path of my project (I only have jasperreports-3.5.3.jar), but I don't know which one.

Here is the code I use to diplay the report:

 

As you can see, it's pretty simple, as thi viewer suits my need perfectly well.

Any help will be highly appreciated.
Thanks in advance.
 

Code:
HashMap parameters = new HashMap();try {    JRXmlDataSource jrxmlds = new JRXmlDataSource(m_xmlDoc, m_recordPath);    parameters.put("SUBREPORT_DIR", m_strPath);    JasperPrint print = JasperFillManager.fillReport(            m_reportFileName,            parameters,            jrxmlds);    JasperViewer jviewer = new JasperViewer(print, false);    jviewer.setTitle(m_strTitle);    jviewer.setVisible(true);} catch (JRException ex) {    JOptionPane.showMessageDialog(null, "JRException!!!\nMessage:\n" + ex.getMessage(), "JRException", JOptionPane.WARNING_MESSAGE);    if (logger.isLoggable(Level.SEVERE)) {        logger.log(Level.SEVERE, null, ex);    }} catch (Exception ex) {    JOptionPane.showMessageDialog(null, "Exception!!!\nMessage:\n" + ex.getMessage(), "JRException", JOptionPane.WARNING_MESSAGE);    if (logger.isLoggable(Level.SEVERE)) {        logger.log(Level.SEVERE, null, ex);    }}
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...