2001 JI Open Discussion Posted August 21, 2006 Share Posted August 21, 2006 By: Michael Mai - mmai reverse jasper to xml 2003-08-19 11:56Hi, Due to my HD crashed, I lost my report xml files. However, I still got *.jasper files. Is there a way to reverse jasper file to xml. Regards, michael By: Michael Mai - mmai RE: reverse jasper to xml 2003-08-19 13:47Thank you for quick response. I got error on first line "Cannot convert from JasperDesign tp JasperReport" Please advise, By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 12:16Yes: JasperReport jasperReport = JasperManager.loadDesign("Whatever.jasper"); JRXmlWriter.writeReport(jasperReport, "Whatever.xml"); By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 14:16Sorry, want relying on memory. Try this: try { JasperReport jasperReport = JasperManager.loadReport("Whatever.jasper"); dori.jasper.engine.xml.JRXmlWriter.writeReport(jasperReport, "Whatever.xml"); } catch (dori.jasper.engine.JRException jasperException) { jasperException.printStackTrace(); } By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 14:25One last sorry. This code WILL work. try { JasperReport jasperReport = JasperManager.loadReport(fileIn); dori.jasper.engine.xml.JRXmlWriter.writeReport(jasperReport, fileOut, "UTF8"); } catch (dori.jasper.engine.JRException jasperException) { jasperException.printStackTrace(); } By: Michael Mai - mmai RE: reverse jasper to xml 2003-08-19 14:37Now I got this error [java] java.io.InvalidClassException: dori.jasper.engine.base.JRBaseReport; local class incompatible: stream classdesc serialVersionUID = 406, local class serialVersionUID = 405 at this line: JasperReport jasperReport = JasperManager.loadReport("WebappReport.jasper"); Please Advise Thanks By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 14:58That error means you are trying to use a different version of JasperReports than the one the .jasper file was created with. By: Hathfuri - hathfuri RE: reverse jasper to xml 2005-02-17 11:40So is this to say that only .jasper files created with the version of Jasper on the server will work? No back-wards compatibility here? This would appear to be a major problem. By: Michael Mai - mmai RE: reverse jasper to xml 2003-08-19 15:07This time I got compiled error: [java] java.lang.Error: Unresolved compilation problem: [java] The method writeReport(JRReport) in the type JRXmlWriter is not applicable for the arguments (JasperReport, String, String) By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 15:15I can no longer help you, then. The code I gave you (the last one) I tested myself and it worked. Here it is again: public static void recreateJasperXML(String fileIn, String fileOut) { try { JasperReport jasperReport = JasperManager.loadReport(fileIn); dori.jasper.engine.xml.JRXmlWriter.writeReport(jasperReport, fileOut, "UTF8"); } catch (dori.jasper.engine.JRException jasperException) { jasperException.printStackTrace(); } } By: Michael Mai - mmai RE: reverse jasper to xml 2003-08-19 15:20Thanks all your help. I will get correct jasperreport and try it again. Regards, Michael By: Gregory A. Swarthout - gswarthout RE: reverse jasper to xml 2003-08-19 15:23I found out I do have one last thing to add. The code I gave you will only work for a report compiled by JasperReports v0.5.0, to get the same code to work with JasperReports v0.4.6, omit the "UTF8" parameter from the writeReport method. 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