Khaled
Khaled

Reputation: 563

Update Table Tree in Confluence via API using Python

i've been trying to get a table from Confluence Page which is located inside another Table, and then add new line to the sub-Table and then upload the new updated Table gain onto Confluence.

Before:

enter image description here

After:

enter image description here

However, due to komplex Structure of the Tables (a table inside a table), when i upload the results, the table's structure gets broken:

enter image description here

My Code snippet:

conf = Confluence(url=conf_site, username=conf_user, password=conf_pass, cloud = True)
print("+++++++Confluence_Object++++++", conf)
# get current page content
page = conf.get_page_by_id(page_id, expand='body.view')
page_content = page['body']['view']['value']

#get table
table = pd.read_html(page_content)

table = table[0] #Only one table on the page
table.loc[len(table.index)] = ['Amy', 89, 93, 100]
#add new column to table
table['E'] = 'Khaled'

#convert table to HTML
newHTML = table.to_html(index=False)

#new page content
page_content = newHTML
print(type(page_content))

print(page_content)

# update page with new content
conf.update_page(page_id, page_title, page_content)

I've looked in many questions regarding this matter, but unfortunately no question handles this situation!!

Upvotes: 0

Views: 83

Answers (0)

Related Questions