StimVinsh / xdocreport

Automatically exported from code.google.com/p/xdocreport
0 stars 0 forks source link

List of values within table cell #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1> Consider below table

Hdr1       Hdr2
Test       Alias1
           Alias2
           Alias3 
Test2      Alias4
           Alias5
           Alias6

The requirement is to have Alias1, Alias2 and Alias3 in the same cell but well 
formatted. Since Alias1 2 and 3 are already part of list field, how to populate 
a list within a list?

What version of the product are you using?  -  0.9.0

On what operating system? windows and linux

Original issue reported on code.google.com by murthy.r...@gmail.com on 12 Aug 2011 at 6:33

Attachments:

GoogleCodeExporter commented 8 years ago
Hi,

I understand what you wish do. I don't know if it's possible to do that but I 
will study that. 

Regards Angelo

Original comment by angelo.z...@gmail.com on 12 Aug 2011 at 9:30

GoogleCodeExporter commented 8 years ago
Hi, 

I have tested with our provided samples (lits of developer) with ODT + Velocity 
(but it will works too with docx and Freemarker).

I will add page in teh wiki to explain how manage list of list in a Table cell.
If you take the sample with developer (docx+velocity) you have : 

 * a list of developer in a Table. You have the field $developers.Name in a inpout file (for ODT) and mergefield (for docx).
 * Velocity Loop for table is generated automaticly because there is Fieldsmetdata FieldsMetadata metadata = new FieldsMetadata();
metadata.addFieldAsList("developers.Name");

With simplification, XDocReport use fieldsmetadata to transform the odt/docx 
original : 

----------------------------------------
<table>
  <row>
    <cell>$developers.Name</cell>
  </row>
<table>
----------------------------------------

with this content : 

----------------------------------------
<table>
  #foreach($item_developers in developers)
  <row>
    <cell>$item_developers.Name</cell>
  </row>
  #end
<table>
----------------------------------------

You can check that XDocReport transform your $developers with $item_developers. 
So if you know that you can manage your list of list.

Imagine you have Developer#getRoles(), and Role#getName() and you put your 
context like this : 

---------------------------------------------
Developer developer = new Developer("ZERR", 
"Angelo",           "angelo.zerr@gmail.com");
developer.addRole(new Role("Role1"));
developer.addRole(new Role("Role2"));
---------------------------------------------

You can write the odt/docx like this : 

----------------------------------------
<table>
  <row>
    <cell>$developers.Name</cell>
    <cell>#foreach ($role in $item_developers.Roles) $role.Name
#end</cell>
  </row>
<table>
----------------------------------------

where Velocity code is included in a input-field/mergefield : 

 * #foreach ($role in $item_developers.Roles) 
 * $role.Name
 * #end

The ouput looks like this : 

----------------------------------------
<table>
  <row>
    <cell>ZERR</cell>
    <cell>Role1
          Role2

    </cell>
  </row>
<table>
----------------------------------------

After Role2 you will extra line break (I don't know for the moment how fix 
that).

Regards Angelo

Original comment by angelo.z...@gmail.com on 12 Aug 2011 at 2:40

GoogleCodeExporter commented 8 years ago
Thanks so much.

Will try that and update you.

Original comment by murthy.r...@gmail.com on 12 Aug 2011 at 5:30

GoogleCodeExporter commented 8 years ago

Original comment by angelo.z...@gmail.com on 1 Nov 2011 at 4:01