Skip to Content
0

Design Studio Crosstab export to Excel, stuck coding

Aug 17, 2017 at 08:59 AM

61

avatar image
Former Member

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!

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
avatar image
Former Member Aug 17, 2017 at 11:54 AM
0

var myArray=[CROSSTAB1]; 
if (CROSSTAB1.getDataSource().isResultSetEmpty()==true) { 
myArray.pop(); 
} 

if (CROSSTAB2.getDataSource().isResultSetEmpty()==false) { 
myArray.push(CROSSTAB2); 
}

 . . . 

APPLICATION.export(ExportType.EXCEL_xlsx,myArray);
Done :)
Share
10 |10000 characters needed characters left characters exceeded