Title: Re: [jXLS-user] Question: Nested Collections (n >= 3)
Hi Mark,

You should probably try it with jx tags.

--
Best regards,
Leo

Thursday, August 1, 2013, 11:00:49 PM, you wrote:


Hi,
 
When using nested collections that are three levels deep, I am unable to get the row total to reflect each single row.  
 
Question
Do JXLS formulas work in the innermost collection of a three-deep structure and on single cells from a collection (vs. an expanded range) as it does with the Total formula in the two-level grouping.xls JXLS example?  If so, how can I fix the error in the formula above.
 
Background
Using a modification of grouping.xls:
 
Department//departments ${departments.name}//:9      
Chief        
Name Age Payment Bonus  
${departments.chief.name} ${departments.chief.age} ${departments.chief.payment} ${departments.chief.bonus}
         
Region: ${departments.regions.name}//:4      
Employees        
Name Age Payment Bonus Total
${departments.regions.employees.name} ${departments.regions.employees.age} ${departments.regions.employees.payment} ${departments.regions.employees.bonus} $[C9*(1+D9)]//departments.regions.employees
Totals:   $[SUM(C8)]   $[SUM(E8)]
 
the “Total” formula, which I modified for an additional nesting level and an extra template row for the region name:
 
From:    $[C8*(1+D8)] //departments.staff
To:     $[C9*(1+D9)]//departments.regions.employees
 
gives the following error during transformation:
 
Parse error near char 8 ',' in specified formula 'C9*(1+D9,D16)'. Expected ')'
 
It’s as though it is trying to expand the D9 in the formula into the range of cells under departments, rather than adjusting to the single cells on the row.
 
Note: I have gotten this to work with jxls:foreach (see attached below), but it is a lot harder to read for a user who I might ask to mock up a report.
 
Test Method
To verify that jxls can handle nested collections with more than two levels, I am using a modified version of GroupingSample.java with modified model classes that allows three levels: 
 
1) Department
2) Region
3) Employees
 
The data comes out fine when I supply ${departments.name}//:9 for the top-level collection and ${departments.regions.name}//:4 for the second-level collection.  However, the modified formulas for the Total in the right-hand side (see above) do not work.  If I just set it to zero to get the rest to work, the column totals are substituted only in the first section.  The remaining sections show the unchanged jxls formula (e.g. literally, “$[SUM(C9)]”). 
 
Artifacts
Jxls:forEach implementation:
Thank You,
Mark McDonald
 




-- 
Best regards,
 leo                            mailto:leo...@inbox.ru
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
jXLS-user mailing list
jXLS-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jxls-user

Reply via email to