Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Rainhard Fischer   on Sep 11 In Java Category.

  
Question Answered By: Muntasir Bashara   on Sep 11

I found solution  by myself, of course!
here is my code (converting jasper  to jrxml)
enjoy now

import java.io.File;

import net.sf.jasperreports.engine.JRException;

import net.sf.jasperreports.engine.JasperReport;
import net.sf.jasperreports.engine.design.JasperDesign;

import net.sf.jasperreports.engine.util.JRLoader;

import net.sf.jasperreports.engine.xml.JRXmlWriter;

public class JasperToJRXML {

public static String sourcePath,
destinationPath,
xml;


public static JasperDesign jd = new JasperDesign();

public static void main(String[] args) throws JRException {


// Paths
File dir = new File("C:\\jaspers\\");


if (dir.isDirectory()) {
File[] jaspers = dir.listFiles();

for (int i = 0; i < jaspers.length; i++) {
String outputPath = "c:\\jrxml\\";
String ext = getFileExtenstion(jaspers[i]);

if (ext.equalsIgnoreCase(".jasper")) {

JasperReport report =
(JasperReport)JRLoader.loadObject(jaspers[i]);
outputPath += getFileName(jaspers[i]) + ".jrxml";
JRXmlWriter.writeReport(report, outputPath, "UTF-8");

}
System.out.println(ext);
}
}

}

private static String getFileExtenstion(File file) {
String fileName = file.getName();
int i = fileName.indexOf(".");
return fileName.substring(i, fileName.length());
}

private static String getFileName(File file) {
String fileName = file.getName();
int i = fileName.indexOf(".");
return fileName.substring(0, i);
}
}

Share: 

 
 
Didn't find what you were looking for? Find more on decompile jasper Or get search suggestion and latest updates.


Tagged: