Jump to content

Change table template in report by python


---
 Share

Recommended Posts

Hello,

How can I change the table template used in the report page using python?

gom.script.table.switch_template (name='template_name') doesn't give a handle to the table to change.

Thanks

Johnny

Link to comment
Share on other sites

  • 4 weeks later...

This might not be the best way to do it, but this script goes through all the report pages that have a table, restores the 3d view, changes the table template, then updates the report page table. You will have to input the name and uuid of your template, the script has placeholders for it. You can get those by recording yourself changing the table template and taking the values from there. Hope this helps

# -*- coding: utf-8 -*-

import gom

for report in sorted(gom.app.project.reports):
	
	for element in report.pages[0].elements:
		
		if 'table' in element.name:
			
			gom.script.report.restore_3d_view_from_report_page (page=[element])
			
			gom.script.table.switch_template (name='YOUR_TEMPLATE_NAME_HERE', uuid='YOUR_TEMPLATE_UUID_HERE')
			
			gom.script.report.overwrite_report_page (target=[report.pages[0].elements[element.name]])

 

Link to comment
Share on other sites

Well this was very help full.

Next step is to get the list of available table templates. I have to figure out how they can be retrieved. Is there something in the api?

Link to comment
Share on other sites

 Share

×
×
  • Create New...