Exportar a Excel un reporte desde java
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.JExcelApiExport erParameter;
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(url reporte);
JasperPrint reporte = JasperFillManager.fillReport(urlreporte, null, con);
JRXlsExporter exporterXLS = new JRXlsExporter();
exporterXLS.setParameter(JExcelApiExporterParamete r.IS_DETECT_CELL_TYPE, Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParamete r.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParamete r.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParamete r.SHEET_NAMES, "Rpt");
exporterXLS.setParameter(JExcelApiExporterParamete r.IGNORE_PAGE_MARGINS , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParamete r.MAXIMUM_ROWS_PER_SHEET,5000);
exporterXLS.setParameter(JExcelApiExporterParamete r.IS_COLLAPSE_ROW_SPAN , Boolean.FALSE);
exporterXLS.setParameter(JExcelApiExporterParamete r.IS_FONT_SIZE_FIX_ENABLED , Boolean.TRUE);
exporterXLS.setParameter(JExcelApiExporterParamete r.JASPER_PRINT_LIST, urlreporte);
exporterXLS.setParameter(JExcelApiExporterParamete r.OUTPUT_FILE, new File(destino));
exporterXLS.setParameter(JExcelApiExporterParamete r.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(Abs tractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.jav a:6516)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3321)
at java.awt.Component.processEvent(Component.java:628 1)
at java.awt.Container.processEvent(Container.java:222 9)
at java.awt.Component.dispatchEventImpl(Component.jav a:4872)
at java.awt.Container.dispatchEventImpl(Container.jav a:2287)
at java.awt.Component.dispatchEvent(Component.java:46 98)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4832)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4492)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4422)
at java.awt.Container.dispatchEventImpl(Container.jav a:2273)
at java.awt.Window.dispatchEventImpl(Window.java:2719 )
at java.awt.Component.dispatchEvent(Component.java:46 98)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava: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.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPri vilege(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.doIntersectionPri vilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 710)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.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.j ava:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:4 25)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 58)
... 39 more
- Inicie sesión o regístrese para enviar comentarios
No encuentra una dependencia
Primero checa que tengas agregados los jars adecuados, y la cuestion siempre es "googlear o no googlear"
NoClassDefFoundError Jar Error for org/apache/poi/ss/usermodel/Sheet