Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

boriscotter
New Contributor II

Using a script to export an QV object to Excel or JPG

I met some problems using a script to export an or more object(s)  to Excel or JPG for example.

My problem was, when I have more one selection, selected by script, some time you unselect one selection because you don't have any records for these selections. When you use QV manually, easy to look about this, but by script ?

I found one solution for this problem. You have to test every time you select a new one if you have already some records for these selections.

This is my PowerShell script

#Select new one selection

$objQVDoc.Fields("Type de commande").Select("CDE")

#Test if the selections are already active for each selection done, in this case tree selections

#I use the variable '$testsel', if is ok, I receive 0, if I don't have any records, I receive -1

[int]$testsel+=$objQVDoc.Evaluate("Isnull(getfieldselections([DtCreat]))")

[int]$testsel+=$objQVDoc.Evaluate("Isnull(getfieldselections([Sitevente]))")

[int]$testsel+=$objQVDoc.Evaluate("Isnull(getfieldselections([Type de commande]))")

#Just before I export the object, I test the value for '$testsel', if I receive 0, ok I export my object

if ([int]$testsel -eq 0) {ExportObjectToJpg "CH53"  ($filePathImg + "cmddetail.jpg")}

Community Browser