Title: Re: [jXLS-user] collection in a second forEach
Hi Florian,

All the syntax options you mentioned should work.
Please share your classes so that we can take a look.
Or sent me an example demonstrating the problem.

--
Leo

Friday, August 19, 2011, 6:14:58 PM, you wrote:


Hello,
 
I am searching for the  best way to do the following:
I want to iterate about my beans and use an excel template.
 
            Map<String, Collection> beans = new HashMap<String, Collection>();
            // ..
            beans.put("nutzer", nutzer);
            XLSTransformer transformer = new XLSTransformer();
            transformer.transformXLS(templateFileName, beans, outputFileName);
          
Each item of the collection  nutzer  should be in a new row.
<jx:forEach items="${nutzer}" var="n">
Text | ${n.getName()}  | …. | ..
</jx:forEach>
 
Every item ‘n’ contains another collection ‘coll’. I do not know the number of item in ‘coll’ at compile time, but I want to have each item in a new columm.
<jx:forEach items="${nutzer}" var="n">
Text | ${n.getName()}  | …. | <jx:forEach items="${ ???}" var="zelle"> |  ${zelle} | </jx:forEach>
</jx:forEach>
 
My problem is to find the correct _expression_ in the inner forEach. 
I have an method called ‘calcColl’ which returns a Collection<String>, but it is not allowed to write 
<jx:forEach items="${ n.calcColl()}" var="zelle">, isn’t it ?
 
Next try : 
I created a private field ‘coll’ and a ‘getColl()’ method :
    public Collection<String> getColl(){
        coll = calcColl();
        returncoll;
    }
And wrote :
<jx:forEach items="${ n.coll}" var="zelle">
But this also did not work. Now I am confused, because if I instantiate ‘coll’ in the constructor with data and use 
      public Collection<String> getColl(){
        returncoll;
    }
everything is fine. Unfortunately I have to calculate ‘coll’ at a later time.
 
What am I doing wrong ?
 
Best regards and thanks for the great library
Florian




-- 
Best regards,
 Leo                            mailto:leon...@gmail.com
------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. http://p.sf.net/sfu/wandisco-d2d-2
_______________________________________________
jXLS-user mailing list
jXLS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jxls-user

Reply via email to