Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Sheet
Te sucede porque JasperReport necesita las clases de Apache POI, y no las encuentra.
Asegúrate de que POI es accesible, incluyéndolo en el classpath en ejecución.
Hola deseo exportar un reporte a excel estoy usando netbeans 4.7 e IReport 4.7, este es mi código:
//Librerías
import java.io.File;
import java.sql.*;
import java.util.HashMap;
import java.util.Map;
import javax.swing.*;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.export.JExcelApiExporterParameter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.util.JRLoader;
String urlreporte = "src/Rpt01.jasper";
String destino = "C:\\Rpt01.xls";
try
{
//Map parametros = new HashMap();
JasperReport jasperReport=(JasperReport)JRLoader.loadObject(urlreporte);
JasperPrint reporte = JasperFillManager.fillReport(urlreporte, null, con);
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JExcelApiExporterParameter.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.SHEET_NAMES, "Rpt");
exporterXLS.setParameter(JExcelApiExporterParameter.IGNORE_PAGE_MARGINS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.MAXIMUM_ROWS_PER_SHEET,5000);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_COLLAPSE_ROW_SPAN , Boolean.FALSE);
exporterXLS.setParameter(JExcelApiExporterParameter.IS_FONT_SIZE_FIX_ENABLED , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParameter.JASPER_PRINT_LIST, urlreporte);
exporterXLS.setParameter(JExcelApiExporterParameter.OUTPUT_FILE, new File(destino));
exporterXLS.setParameter(JExcelApiExporterParameter.CHARACTER_ENCODING, "UTF-8");
exporterXLS.exportReport();
}
catch(Exception e)
{
System.err.println( "Error iReport: " + e.getMessage() );
}
y este es el error que me manda:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Sheet
at Inicio.Rpt1ActionPerformed(Inicio.java:107)
at Inicio.access$000(Inicio.java:17)
at Inicio$1.actionPerformed(Inicio.java:63)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6516)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
at java.awt.Component.processEvent(Component.java:6281)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4872)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
at java.awt.Component.dispatchEvent(Component.java:4698)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
at java.awt.Container.dispatchEventImpl(Container.java:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719)
at java.awt.Component.dispatchEvent(Component.java:4698)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:740)
at java.awt.EventQueue.access$300(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:699)
at java.awt.EventQueue$3.run(EventQueue.java:697)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:713)
at java.awt.EventQueue$4.run(EventQueue.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:710)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Caused by: java.lang.ClassNotFoundException: org.apache.poi.ss.usermodel.Sheet
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 39 more