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

Word format has boxes around report elements


ns69

Recommended Posts

Hi All,

 

I am exporting the reports in various formats in my web application, but the word format has boxes around each report elements. It looks very weird. Anyone has encountered the same formatting issue? How to get rid of these lines from the report?

 

Thanks in advance.

Link to comment
Share on other sites

  • 2 months later...
  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

In any case, the RTF you attached is NOT the exact RTF output produced by JasperReports.

I have looked into it, I have read the markup tags and that is not what JasperReports generates.

 

I suspect you open the original RTF document generated by JR inside some RTF editor and you save it back. The resulting document is different from what JR has generated. Some sort of conversions take place, which introduce these borders.

 

I hope this helps.

Teodor

Link to comment
Share on other sites

You are right the rtf file was opened by the word application and saved.

 

Here is the rtf file generated by JR. You will also find the .jrxml file as attachment created in iReport. I have also included the java code for your review.

 

Thanks,

NS.

 

Code:
   public static void genWordReport(JasperPrint jasperPrint, HttpServletResponse response, OutputStream ouputStream, String saveAsName){
try{
response.reset();
// response.setHeader("Expires", "0"«»);
//response.setHeader("Content-Disposition", "inline;filename=" + saveAsName.concat(".doc"«»));
response.setHeader("Content-Disposition", "attachment;filename=" + saveAsName.concat(".rtf"«»));
response.setContentType("application/ms-word"«»);
response.setHeader("Cache-Control","must-revalidate, post-check=0, pre-check=0"«»);
response.setHeader("Pragma", "public"«»);

net.sf.jasperreports.engine.export.JRRtfExporter exporter = new net.sf.jasperreports.engine.export.JRRtfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, saveAsName.concat(".doc"«»));
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, ouputStream);
exporter.setParameter(JRExporterParameter.OFFSET_X, new Integer(20));
exporter.setParameter(JRExporterParameter.OFFSET_Y, new Integer(15));
exporter.exportReport();

}
catch(Exception er){
String connectMsg = "Could not create the Word report " + er.getMessage() + " " + er.getLocalizedMessage();
System.out.println(connectMsg);
}
} [file name=testrep.zip size=25634]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/testrep.zip[/file]
Link to comment
Share on other sites

Hi,

 

As you can see the RTF generated by JasperReports does not have any unwanted borders around the text fields. Any extra border you showed us is introduced by the MS Word editor when you save it.

 

You should have told us so from the beginning that you edit the file in Word. It would have saved us time.

Just as a curiosity, what version of MS Word is it?

 

I consider this matter closed. This problem should be reported to Microsoft, as our RTF exporter fully complies with the RTF specifications (wrote by Microsoft themselves).

 

Thanks,

Teodor

Link to comment
Share on other sites

I am using MS Office Word 2003 SP3. As you can see from my code I am just initializing the response objrct content type to word application to open the .rtf file (created by JR) in the client browser window. Sorry for the confusion.

 

Thanks a lot for all your help.

Regards,

Neeta

Link to comment
Share on other sites

  • 4 months later...
  • 1 month later...

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...