##UPDATE
I just re read your message and noticed this wont work for you. Sorry.
This have been doing the trick for me.
For the html template:
<table>
<thead>
<tr>
<!-- tmpl_loop name="fields" -->
<th><!-- tmpl_var name="field" --></th>
<!-- /tmpl_loop -->
</tr>
</thead>
<tbody>
<!-- tmpl_loop name="data" -->
<tr>
<!-- tmpl_loop name="cols" -->
<td><!-- tmpl_var name="value" --></td>
<!-- /tmpl_loop -->
</tr>
<!-- /tmpl_loop -->
</tbody>
</table>
And, the perl part:
my @fields = qw(your columns names here);
$object->get_all(%params);
while (my $obj = $object->get_next){
my @row = map {{value => $obj->$_}} @fields;
push @data, {cols => \@row};
}
$template->param(fields => \@fields);
$template->param(data => \@data);
Hope this helps.