Using #forcol in table, but need to omit first column

Uploaded report templates and discussions about reports.

Moderators: sarawut_w, Moderators

Using #forcol in table, but need to omit first column

Postby JG_ » Thu Jan 20, 2022 5:49 pm

Hi there,

I am using #forcol in a table (in a Word template) to pull data from a model. I need to ignore the first column. It seems like $table.getVisibleColumnIds() isn't exactly a List so some of the associated methods don't work.

Here's what I would theoretically like to do.
Code: Select all
#forcol($id in $table.getVisibleColumnIds().slice(1))$table.getColumn($id)#endcol

Here's what I've gotten, but it's not working...seems like I can't iterate through $cols.
Code: Select all
#set($cols = [])#set($tempSize = $table.getVisibleColumnIds().size() - 1)#foreach($i in [1..$tempSize])#set($id = $table.getVisibleColumnIds().get($i))#set($ignore = $cols.add($id))#end#forcol($id in $cols)$table.getColumn($id)#endcol

Any solutions would be appreciated!
JG_
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:2
Joined: Thu Jan 20, 2022 5:38 pm
Full name: JG

Re: Using #forcol in table, but need to omit first column

Postby JG_ » Thu Jan 20, 2022 6:28 pm

I've actually made some progress, but am now stuck again.

This code works for the header.
Code: Select all
#set($cols = [])#set($tempSize = $table.getVisibleColumnIds().size() - 1)#foreach($i in [1..$tempSize])#set($id = $table.getVisibleColumnIds().get($i))#set($ignore = $cols.add($id))#end#forcol($i in [0..$cols.size()])$table.getColumn($cols.get($i))#endcol

This code almost works for the body of the table, but I am encountering an issue defining the size of the range in the #forcol loop.
Code: Select all
#forrow($row in $table.getRows())
#set($cols = [])#set($tempSize = $table.getVisibleColumnIds().size() - 1)#foreach($i in [1..$tempSize])#set($id = $table.getVisibleColumnIds().get($i))#set($ignore = $cols.add($id))#end#forcol($i in [0..3])
$table.getValueAsString($row, $cols.get($i))
#endcol#endrow

If I try to replace the 3 in $i in [0..3] with anything else (ideally I would use $tempSize here), the entire table doesn't get output.
JG_
Forum Newbie
Forum Newbie
 
Posts: 2
Posts Rating:2
Joined: Thu Jan 20, 2022 5:38 pm
Full name: JG


Return to Report Engine

Who is online

Users browsing this forum: No registered users and 0 guests