You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I can update a table on a confluence page using something like this:
from atlassian import Confluence
import pandas as pd
conf_site = 'https://your-domaine.com/'
conf_user = {username}
conf_pass = {password}
page_title = {pageTitle}
page_space = {pageSpace}
page_id = {pageID}
# connect to Confluence
conf = Confluence(url=conf_site, username=conf_user, password=conf_pass)
# 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
#add new column to table
table['D'] = ''
#convert table to HTML
newHTML = table.to_html(index=False)
#new page content
page_content = newHTML
# update page with new content
conf.update_page(page_id, page_title, page_content)
However, what do I do when I want to update a table inside a Table Excerpt?
I have tried to modify the entire page_content including <div> , classes etc. and send it back to confluence. However the table I end up with is no longer inside a Table Excert.
Any suggestions how to do this?
Hi @Tola,
Yes, it is possible to do. The only thing you need to change is the page body type from view to storage.
Pages are stored in the storage (XHTML) format in Confluence. It differs from what you see when viewing the page in a browser: links, macros, and other entities are stored in a different format. So when you update a page, you need to make updates in the storage format.
The first thing you need to change is this:
# get current page content
page = conf.get_page_by_id(page_id, expand='body.storage')
page_content = page['body']['storage']['value']
Then you need to work with XHTML, so you might need to parse it in a different way.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please post what you did to convert the HTML to XHTML? I am currently trying to update values in a table on a Confluence page.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.