Closed GoogleCodeExporter closed 8 years ago
Hi,
I'm sorry but I can do nothing with your info.
Could you attach your docx + java code (main+pojo) please.
Many thank's
Regards Angelo
Original comment by angelo.z...@gmail.com
on 11 Jun 2012 at 11:14
yes ;), thnak you and here is the exact function that i'm calling for
generating the docx
public void genererrapport(){
//int idaudit=getId();
//String organismeaudite = getOrganismeAudite().getNom();
Audit a = new Audit();
a=resp.findById(id);
try
{
InputStream in = new FileInputStream( "C:\\Users\\noor\\Desktop\\rapport.docx" );
IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity );
// 2) Create context Java model
String code="cooooode",datejour="28/05/2012",nbrecart="7",nbrecar3b="2",nbrecar3a="2",nbrecar2="2",nbrecar1="1";
DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyyd");
Date date = new Date();
IContext context = report.createContext();
Project project = new Project(a.getOrganismeAudite().getNom()); context.put( "aeroport", project );
project = new Project(a.getDate()); context.put( "dateaudit", project );
project = new Project(a.getOrganismeAudite().getVille()); context.put("villeorganismeaudite", project);
project = new Project(code); context.put("code", project);
project = new Project(dateFormat.format(date)); context.put("datejour", project);
project = new Project(nbrecart); context.put("nbrecart", project);
project = new Project(nbrecar3b); context.put("nbrecar3b", project);
project = new Project(nbrecar3a); context.put("nbrecar3a", project);
project = new Project(nbrecar2); context.put("nbrecar2", project);
project = new Project(nbrecar1); context.put("nbrecar1", project);
// 2) Create fields metadata to manage lazy loop (#forech velocity)
// for table row.
// 3) Create context Java model
FieldsMetadata metadata = report.createFieldsMetadata();
metadata.addFieldAsList( "developers.Name" );
metadata.addFieldAsList( "developers.LastName" );
metadata.addFieldAsList( "developers.Mail" );
/*project = new Project( "XDocReport" );
context.put( "project", project );*/
// context.put( "project", project );
List<Developer> developers = new ArrayList<Developer>();
developers.add( new Developer( "mmm", "mmmm", "angelo.zerr@gmail.com" ) );
developers.add( new Developer( "Leclercq", "Pascal", "pascal.leclercq@gmail.com" ) );
context.put( "developers", developers );
// 3) Generate report by merging Java model with the Docx
OutputStream out = new FileOutputStream( new File( "C:\\Users\\noor\\Desktop\\rapport_Out.docx" ) );
report.process( context, out );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( XDocReportException e )
{
e.printStackTrace();
}
}
i'v attached the .java that i'm calling, but it's calling other .java, do i
need to send them all?? their qiut a few.
Original comment by nourelho...@gmail.com
on 11 Jun 2012 at 11:21
Attachments:
Hi,
please create a sample which works (every the java classes that you use) in
order to I can run your sample with your problem.
I suggest you to test what is the problem to remove some content of your docx,
you generate and you check if it's OK. As soon as it's OK, you readd the
content which crashes your report. You will find what is the problem after.
It will help me alot if you can do that.
Thank's.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 11 Jun 2012 at 11:35
will do as soon as i get the chance to work on my project:)
thanks again
Original comment by nourelho...@gmail.com
on 11 Jun 2012 at 11:41
I think it's because of bookmark (signet) "OLE_LINK1" and "OLE_LINK2" of your
docx. Try to remove it from your rapport.docx. I suppose it's a bug of
XDocReport which doesn't manage well the bookmark which must be kept.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 11 Jun 2012 at 2:03
thanks it was the bookmars that were the cause of trouble
Original comment by nourelho...@gmail.com
on 12 Jun 2012 at 3:11
Yes the problem comes from with bookmark which are included into loop
(#foreach). So it generate several bookmark with the same id, which is not
allowed for docx.
I close this bug.
Regards Angelo
Original comment by angelo.z...@gmail.com
on 22 Jun 2012 at 10:11
Original issue reported on code.google.com by
nourelho...@gmail.com
on 11 Jun 2012 at 11:06