Skip to Content
0
Former Member
Aug 17, 2017 at 08:59 AM

Design Studio Crosstab export to Excel, stuck coding

272 Views

Hi there,

I have build an application with multiple tabs, each tab has it own report number dropdown menue (1 to 10) and each tab has it own filters and start button for the query.

When clicking start, a pop-up dialog with the results of the queries appears, depending on the report number selection there are multiple tabs (1-10). Now there is a Export to Excel button which needs to be scripted.

Exporting to Excel in Standard:
APPLICATION.export(ExportType.EXCEL_xlsx,Crosstab1);

Exporting multiple crosstabs to Excel:
APPLICATION.export(ExportType.EXCEL_xlsx, [Crosstab1, Crosstab2, ... ] );

But how do I code a export for all 10 possible Crosstabs? I dont want to export crosstabs when there is no data inside, so I tried:

var x= Crosstab_1,Crosstab_2,Crosstab_3,Crosstab_4,Crosstab_5,Crosstab_6,Crosstab_7,Crosstab_8,Crosstab_9,Crosstab_10];
x.forEach(function(element, index) {
if (element.getDataSource().isResultSetEmpty()==true){
x.pop();
} });
APPLICATION.export(ExportType.EXCEL_xlsx,x,ExportSettings.CSV_SEPARATOR_COMMA);

Error Log says:

"Cannot call method "isResultSetEmpty" of null (BIAL Script #88)"

Any ideas ? Thanks in advance!