sudheer Posted June 20, 2011 Share Posted June 20, 2011 JasperFillManager.fillReportToFile("C:/test/templates/CustomersReport.jasper", params);how can i solve this problem.calling this is giving me the exception.when i searched in net that i need to set dependencies.but i am using a simple java program in eclise..not runnning thru ant task how to set dependencies. i am adding the code snippet also.i just added the jars which are given in jasperreports-4.0.2-project.thanks, Sudheer Code:import java.io.File;import java.util.HashMap;import java.util.Locale;import java.util.Map;import net.sf.jasperreports.engine.JRExporterParameter;import net.sf.jasperreports.engine.JRParameter;import net.sf.jasperreports.engine.JasperFillManager;import net.sf.jasperreports.engine.JasperPrint;import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;import net.sf.jasperreports.engine.query.JRXPathQueryExecuterFactory;import net.sf.jasperreports.engine.util.JRLoader;import net.sf.jasperreports.engine.util.JRXmlUtils;import org.w3c.dom.Document;public class JXLReport { public static void main(String[] args) { try { fill(); docx(); } catch (Exception e) { e.printStackTrace(); } } public static void docx() throws Exception{ File sourceFile = new File("C:/test/templates/CustomersReport.jrprint"); JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".docx"); JRDocxExporter exporter = new JRDocxExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, destFile.toString()); exporter.exportReport(); } @SuppressWarnings("unchecked") public static void fill() throws Exception{ //map data Map params = new HashMap(); Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream("C:/test/data/northwind.xml")); params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document); params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd"); params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##"); params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH); params.put(JRParameter.REPORT_LOCALE, Locale.US); try{ JasperFillManager.fillReportToFile("C:/test/templates/CustomersReport.jasper", params); }catch (Exception e){ System.out.println("----------------"); e.printStackTrace(); } }}Post Edited by sudheer at 06/20/2011 11:02 Link to comment Share on other sites More sharing options...
augarte Posted June 20, 2011 Share Posted June 20, 2011 Have you included Xalan jar file? I don't know if it is inside the Jasper libraries you mention but the class that is missing is in this library: http://xml.apache.org/xalan-j/apidocs/org/apache/xpath/class-use/CachedXPathAPI.htmlTry downloading the jar and adding it your classpath. This should fix your problem. Hope this helps. Regards,Aitor Link to comment Share on other sites More sharing options...
sudheer Posted June 20, 2011 Author Share Posted June 20, 2011 i have included xalan-2.7.1.jar and my problem is solved.hey thank you very much . Link to comment Share on other sites More sharing options...
c1247847 Posted March 20, 2019 Share Posted March 20, 2019 Remove import org.apache.xpath.operations.String;[/code] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now