Jump to content
We've recently updated our Privacy Statement, available here ×

Word document (.doc) encoding


jsanjuan

Recommended Posts

Hi,

I'm working on a Java application with the jasperreports library, and I want to export a report to a .doc document. It creates well the archive, but when I try to open it I get only strange characters. This is my code:

 

JasperReport jasperReport = JasperCompileManager.compileReport("C:/Users/practicas2/Desktop/helloJasperReportXML.jrxml");
        JRXmlDataSource xmlDataSource = new JRXmlDataSource("C:/Users/practicas2/Desktop/data.xml","users//user");
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), xmlDataSource);
        JasperExportManager.exportReportToPdfFile(jasperPrint, "C:/Users/practicas2/Desktop/report_from_xml.pdf");

        JRDocxExporter exporter = new JRDocxExporter();

        File archivo = new File("C:/Users/practicas2/Desktop/report_from_xml.doc");
        FileOutputStream os = new FileOutputStream(archivo);

        exporter.setParameter(JRDocxExporterParameter.JASPER_PRINT, jasperPrint);
        exporter.setParameter(JRDocxExporterParameter.CHARACTER_ENCODING, "UTF-8");
        exporter.setParameter(JRDocxExporterParameter.OUTPUT_STREAM, os);
     
        exporter.exportReport();

        os.close();

 

Anybody knows why?

Thanks.



Post Edited by jsanjuan at 07/19/2010 11:13
Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...