Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to create a table in a sheet using Qlik Sense Engine API?

Hello!

I have a problem with Qlik Sense Engine API and will be glad if you can help me.

I try to create a table in a sheet. I use CreateChild method according qlik.help (https://help.qlik.com/en-US/sense-developer/April2018/Subsystems/EngineAPI/Content/WorkingWithAppsAn...). There isn't a mistake but I can't see the table in the sheet.  What shuld I do for creating a table?

2 Replies
Øystein_Kolsrud
Employee
Employee

You'll need to add the created object to a cell in the sheet properties as well. I recommend you download this tool:

https://community.qlik.com/docs/DOC-17475

Through that tool you can navigate to the sheet object and look at it's properties. That should give you a clearer picture of how the sheet object stores its properties.

I'm not sure what technology you are using for your API calls, but if you use the .Net SDK you can also leverage this method which will make sure the created object is added correctly to the sheet properties as well:

https://help.qlik.com/en-US/sense-developer/April2018/apis/net+sdk/html/Overload_Qlik_Sense_Client_I...

liuis
Contributor II
Contributor II

In case anybody will need more details, here is how to create a copy of an object (chart, table) with API, step by step

1. Get the source object properties ('query' here stands for a function that returns the API response):

source_properties = query({
"jsonrpc": "2.0",
"id": 2,
"method": "GetProperties",
"handle": source_object.handle,
"params": []
})

2. Create a child on a target sheet

create_child = query({
"jsonrpc": "2.0",
"id": 2,
"method": "CreateChild",
"handle": source_sheet.handle,
"params": [
source_properties['result']['qProp']
]
})

Now the object is created but not visible yet, to make it visible we have to edit the target sheet itself.

3. Get the ID of the child created (from the API response)

new_object_id = create_child['result']['qReturn']['qGenericId']

4. Get properties of the target sheet

target_sheet_properties = query({
"jsonrpc": "2.0",
"id": 2,
"method": "GetProperties",
"handle": target_sheet.handle,
"params": []
})

5. Add new object to the cells list of the sheet

target_sheet_properties['result']['qProp']['cells'].append({'name': new_object_id,
'type': 'table',
'col': 1,
'row': 7,
'colspan': 4,
'rowspan': 4,
'bounds': {'y': 66.66666666666666,
'x': 45.83333333333333,
'width': 16.666666666666664,
'height': 33.33333333333333}})

6. Apply SetProperties method to the target sheet.

query({
"jsonrpc": "2.0",
"id": 2,
"method": "SetProperties",
"handle": sh.handle,
"params": [target_sheet_properties['result']['qProp']]
})

If any master measures or master dimension are used in the object, you'll probably have to change their ID's before creating a child (step 2), since the same master measures can have different IDs in the target app.

If you use Python, there is another way to copy objects or sheets using qsea package:

source_app.sheets['source_sheet'].copy(target_app)
source_app.sheets['source_sheet'].objects['source_object_id'].copy(target_app, target_sheet)