llokk2007 Posted November 24, 2013 Share Posted November 24, 2013 Hello, I need some help:)I try to make pdf/html file from XML filein pdf I can see names of colomns, but in nodes: NULL NULL NULL NULLwhat can I do?p.s. sorry for my English)))my code://so datasource is a way to XML file, xpath = "XPath", template is a way to .jrxml file, resultpath - name of report file(ends with .pdf or .html)public static void printpdfhtml(String datasource, String xpath, String template, String resultpath) { try { JRXmlDataSource ds = new JRXmlDataSource(datasource); JasperReport jasperReport = JasperCompileManager.compileReport(template); JasperPrint print = JasperFillManager.fillReport(jasperReport, new HashMap(), ds); if(resultpath.toLowerCase().endsWith("pdf")) JasperExportManager.exportReportToPdfFile(print, resultpath); else JasperExportManager.exportReportToHtmlFile(print, resultpath); } catch (JRException e) { log.info("Исключительная ситуация",e); e.printStackTrace(); } } Link to comment Share on other sites More sharing options...
abhimanyu.prasad Posted November 27, 2013 Share Posted November 27, 2013 Could you please share how you are retrieving the values in the JRXML? Link to comment Share on other sites More sharing options...
llokk2007 Posted November 27, 2013 Author Share Posted November 27, 2013 abhimanyu.prasad, I make a template in iReport, so I don't think its a reason, because when I make for example"PDF Preview" PDF creates correctly...in "report Query" I set "XPath", nodes of XML "tree", drug-and-drop fields, then in report I add fields to DetailField... Link to comment Share on other sites More sharing options...
Solution abhimanyu.prasad Posted November 28, 2013 Solution Share Posted November 28, 2013 Hi llokk2007,Modify your code flow to something like below:JasperDesign jasperDesign = JRXmlLoader.load(sourceFileName);JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);JRXmlDataSource xmlDataSource = new JRXmlDataSource(inputStream, jasperReport.getQuery().getText());JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, xmlDataSource);JasperExportManager.exportReportToPdfFile(jasperPrint, resultpath);[/code]If you are good with your jrxml, then this will definitely do it for you. Let me know if you still face the same issue. Link to comment Share on other sites More sharing options...
gentoo1993 Posted November 28, 2013 Share Posted November 28, 2013 It's perfectly work. Thanks! Link to comment Share on other sites More sharing options...
llokk2007 Posted November 28, 2013 Author Share Posted November 28, 2013 It's great! Thank you very much!!=) 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