Render attachment that is in storage format
Asked by Dan:

I have the following issue. I routinely need to get tables into confluence that contain data generated by some other unrelated tool. I can fairly easily generate my tables in storage format and then copy/paste directly into the confluence source editor. However, this is very inefficient, especially if the tables need to change.

Is there any simple way that would let me just upload these generated tables as attachments and then in the body of the document have some macro that expands the contents of the attachment? To be more concrete, here is an example:

file "cakes.xml" (what would a good file extension for storage format be?)

--------------------

\<ac:rich-text-body\>

\<table class="wrapped"\>

\<colgroup\> \<col/\> \<col/\> \</colgroup\>

\<tbody\>

\<tr\>\<th\>Name\</th\>\<th\>Calories\</th\>\<th\>Cost\</th\>\</tr\>

\<tr\>\<td\>Chocolate\</td\>\<td\>1200\</td\>\<td\>$5.00\</td\>\</tr\>

\<tr\>\<td\>Lemon\</td\>\<td\>1300\</td\>\<td\>$4.00\</td\>\</tr\>

\</tbody\>

\</table\>

\</ac:rich-text-body\>

-------------------

when I have images attached to a page, I can have something like this in the body of my document:

\<ac:image ac:height="400"\>  
\<ri:attachment ri:filename="my_image.png" ri:version-at-save="2" /\>  
\</ac:image\>

and if I upload a new version of "my_image.png" to the page then the displayed image updates. I'd like a similar way to say "show my attached table here". And then if I simply upload a new version of the table, I'd get it. My alternative right now is to use some awful mess of REST calls to download the page via python, locate the old table (how?), replace the old table, and then upload back.


Answers:
author: Shannon S
body: Dan,

What if you were to use the 3rd-party [HTML macro](https://marketplace.atlassian.com/apps/1212279/html-macro-for-confluence-cloud?hosting=cloud&tab=overview) or insert the table as an Excel document using [Display Files and Images](https://confluence.atlassian.com/confcloud/display-files-and-images-724765104.html) (internal Confluence feature).

Would one of those work for you? If not, can you let us know why they might not meet your requirements?

Regards,

Shannon

comments: author: Dan
body: Thanks for the suggestions. I just looked into them and I don't believe they will fill our needs.

Regarding the HTML macro it appears that you have to paste the HTML into the box for the macro which is different from having the macro reference an attachment.

Regarding the Display Files and Images, I tried uploading a spreadsheet (mildly painful because the tools generating our tables work well with ASCII files but can't directly create an excel file). This causes me to just get a thumbnail of a spreadsheet that can be expanded to a preview but that looks quite a bit different from an actual table. Some of the limitations include not being able to search in the page for text which may be in the table when it is just a preview of a spreadsheet.

I'm finding even the approach of downloading the page via the REST API and replacing a table with a new version to be painful because I don't see any clean way to identify a table by some name in the page. In other words, I can, with python find tables in a page but it is hard to identify which table from several tables. Having a name attribute for a table could help I'm sure.

-Dan


author: Shannon S
body: Dan,

The HTML macro page says that it allows you to embed data from another site, so I figured you could store the tables in another format on your web server and reference them that way. I haven't personally used this add-on myself, so I cannot confirm the extent of that functionality, but it would be worth using the trial period.

For the Display Files and Images tool, you would indeed need the table to be in a format such as Excel and display this way. It's the only workaround in Cloud Confluence that's built-in where you could do this.

As the solutions I've suggested aren't a match for you, I'm including your question in the Marketplace Apps collection. This way, if anyone is aware of a 3rd-party app that could help you, they will be able to reach out to you via this thread.

Regards,

Shannon


author: Dan
body: As a note, and this is still a big limitation for me with confluence, we're using cloud confluence so the suggestion of storing tables in another format on our web server won't really work because we don't have such a server.

I do appreciate your time and all the suggestions even if we're not to a solution.

-Dan


Tags: atlassian-marketplace

cloud

confluence-cloud