[ic] [query2xls] tag interpolation

Stefan Hornburg (Racke) racke at linuxia.de
Sun Dec 27 15:01:21 UTC 2009


Rick Bragg wrote:
> Hi,
> 
> Does anybody know how I could get the query2xls tag to interpolate?
> For example, I would like to do something like the following:
> 
> [tmp sql]SELECT * FROM tablename WHERE code = '1'[/tmp]
> 
>   [query2xls interpolate=1
>     query.sheetname1="[scratch sql]"
>     file-name="file-to-create.xls" 
>     base.tablename
>     width=25
>     deliver=1
>   ]
> 
> Actually, I would like to loop through the entire query.## area like
> this:
> 
>   [query2xls interpolate=1
>     [loop prefix=q list="1..[scratch q_count]" ranges=1]
>         query.[calc] $Tag->scratch({ name => sheet_name_[q-code], });[/calc]="[calc] $Tag->scratch({ name => sql_[q-code], });[/calc]"
>     [/loop]
>     file-name="file-to-create.xls" 
>     base.tablename
>     width=25
>     deliver=1
>   ]
> 
> Anybody know the best way to do this?

It looks like that your objective is to loop through a number of SQL queries and produce a XLS file with one
sheet for each SQL query. My suggestion is to collect the queries inside a [calc] or [perl] block and pass
them to your [query2xls] tag with the backtick notation.

[calc]
$Scratch->{xlsqueries} = ['select foo FROM bar', 'select bar FROM foo', 'select * from foobar'];
return;
[/calc]

[query2xls
	queries=`$Scratch->{xlsqueries}`
/]

Regards
         Racke



-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team




More information about the interchange-users mailing list