Export charts from Qlik Sense apps for non-interactive use
This guide demonstrates how to export chart objects from a Qlik Sense app using qlik-cli and a bash or Powershell script. This is useful for automation, documentation, embedding, or further analysis outside of Qlik Sense.
Prerequisites
- qlik-cli installed on a computer with bash or Powershell available.
- If running this script against a Qlik Cloud tenant, create or activate a qlik-cli context for Qlik Cloud.
- IIf running this script against a Qlik Sense Enterprise client-managed site, create or activate a qlik-cli context for Qlik Sense Enterprise client-managed.
- Access to the app you want to export objects from with the configured context and user defined in the context (which may not be the same user as your interactive login user if using JWT or OAuth2).
- If following the bash example:
- jq installed for JSON processing.
Usage
These scripts can be run manually, or by an external scheduler to create JSON files containing the current visible data for Qlik Sense charts.
In Qlik Sense Enterprise client-managed, this can be run on a scheduler node on the site using an external program task that it is triggered immediately after a Qlik Sense app is reloaded.
Output
- Each exported object will be saved as
<appId>/<objectId>.json
in the current directory. - Only objects matching the allowed types will be exported.
Code example
Both examples will work against either Qlik Cloud or Qlik Sense Enterprise client-managed, but are included because it’s often easier to run Powershell natively on Windows servers for client-managed.
Bash
Export all default chart types from an app:
./get-all-app-objects.sh 0ef9c2e0-a9d7-4a54-912b-1d982effdf38
Export only barcharts and piecharts:
./get-all-app-objects.sh 0ef9c2e0-a9d7-4a54-912b-1d982effdf38 barchart,piechart
#!/bin/bash
# Usage: ./get-all-app-objects.sh <appId> [allowedTypes]## <appId>: Qlik Sense App ID# [allowedTypes]: (Optional) Comma-separated list of allowed chart types.# Defaults to `barchart,boxplot,bulletchart,combochart,distributionplot,gauge,histogram,# kpi,linechart,mekkochart,piechart,scatterplot,treemap,waterfallchart`.## This script requires qlik-cli to be installed and the relevant tenant context to be active.## This script lists all objects in the given app, filters them by the allowed chart types,# and stores each object's layout as <appId>/<objectId>.json in the current directory.
set -e
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then echo "Usage: $0 <appId> [allowedTypes]" exit 1fi
appId="$1"if [ -n "$2" ]; then allowedTypes="$2"else allowedTypes="barchart,boxplot,bulletchart,combochart,distributionplot,gauge,histogram,kpi,linechart,mekkochart,piechart,scatterplot,treemap,waterfallchart"fi
# Create output directory if it doesn't existmkdir -p "$appId"
# Get all objects in the app as JSONobjects=$(qlik app object ls --app "$appId" --json)
# Filter objects by allowed types and extract qId and qTypeIFS=',' read -ra types <<< "$allowedTypes"jq_types=$(printf '"%s",' "${types[@]}")jq_types="${jq_types%,}" # Remove trailing commafiltered=$(echo "$objects" | jq -c ".[] | select(.qType | IN($jq_types)) | {qId, qType}")
# Iterate and fetch layout for each filtered objectecho "$filtered" | while read -r obj; do qId=$(echo "$obj" | jq -r '.qId') qType=$(echo "$obj" | jq -r '.qType') echo "Exporting $qType ($qId)" qlik app object layout "$qId" --app "$appId" > "$appId/$qId.json"done
Powershell
Export all default chart types from an app:
./get-all-app-objects.ps1 -appId 0ef9c2e0-a9d7-4a54-912b-1d982effdf38
Export only barcharts and piecharts (comma-separated list):
./get-all-app-objects.ps1 -appId 0ef9c2e0-a9d7-4a54-912b-1d982effdf38 -allowedTypes barchart,piechart
If you are running this locally on a Qlik Sense Enterprise client-managed site,
you may be using unsigned certificates, in which case use the -insecure
flag.
This can be configured as an external program task in Qlik Sense Enterprise client-managed. As an example, on Windows Server 2019, the task should be created with a config like this:
- Path:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
- Parameters:
\\server\QlikShare\scripts\get-all-app-objects.ps1 -appId b1e3643e-c2c6-4e35-a11d-5b6ce1815c7e -insecure
This assumes your script is stored on your central share. You can then add triggers which are hooked onto reload tasks to initiate the export immediately after the app is reloaded.
# Usage:# ./get-all-app-objects.ps1 -appId <appId> [-allowedTypes "<types>"] [-insecure]## -appId Qlik Sense App ID (required)# -allowedTypes (Optional) Comma-separated list of allowed chart types. Enclose in quotes if sending multiple types.# Defaults to barchart,boxplot,bulletchart,combochart,distributionplot,gauge,histogram,kpi,linechart,mekkochart,piechart,scatterplot,treemap,waterfallchart# -insecure (Optional) Passes --insecure to qlik-cli calls (for self-signed certs, etc)## This script requires qlik-cli to be installed and the relevant tenant or site context to be active.## This script lists all objects in the given app, filters them by the allowed chart types,# and stores each object's layout as <appId>/<objectId>.json in the current directory.
param( [string]$appId, [string]$allowedTypes = "barchart,boxplot,bulletchart,combochart,distributionplot,gauge,histogram,kpi,linechart,mekkochart,piechart,scatterplot,treemap,waterfallchart", [switch]$insecure)
# Set insecure flag for qlik calls if requested$insecureFlag = if ($insecure) { '--insecure' } else { '' }
# Validate required appId (must not be empty or start with '-')if (-not $appId -or $appId -like '-*') { Write-Host "Usage: ./get-all-app-objects.ps1 -appId <appId> [-allowedTypes \"<types>\"] [-insecure]" exit 1} else { Write-Host "Using App ID: $appId"}
# Create output directory if it doesn't existif (-not (Test-Path $appId)) { New-Item -ItemType Directory -Path $appId | Out-Null}
# Get all objects in the app as JSON$objects = qlik app object ls --app $appId $insecureFlag --json | ConvertFrom-Json
# Split allowed types into an array (comma-separated, trims whitespace)$typeList = $allowedTypes -split ',' | ForEach-Object { $_.Trim() } | Where-Object { $_ -ne '' }
# Filter objects by allowed types and extract qId and qType$filtered = $objects | Where-Object { $typeList -contains $_.qType } | Select-Object qId, qType
# Iterate and fetch layout for each filtered objectforeach ($obj in $filtered) { $qId = $obj.qId $qType = $obj.qType Write-Host "Exporting $qType ($qId)" qlik app object layout $qId --app $appId $insecureFlag | Out-File -Encoding utf8 "$appId/$qId.json"}
# Log results to results.log$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"$logFile = "results.log"$params = "appId=$appId, allowedTypes=$allowedTypes, insecure=$insecure"$result = "Exported $($filtered.Count) objects to $appId directory."$logEntry = "[$timestamp] Params: $params`nResult: $result`n"Add-Content -Path $logFile -Value $logEntry
# Notify completionWrite-Host "Export completed. $($filtered.Count) objects saved in $appId directory."