Table of Contents
Motivation
Migrating old documentation from Microsoft Excel into Atlassian Confluence I was bamboozled that I couldn’t simply copy paste excel data into Confluence Tables. Duh!
Googling around for a couple of minutes a provided solution looked like that:
- Convert Excel to markdown
- Use the “Insert markdown” macro in Confluence
Excel to markdown
There are several ways to convert Excel to markdown:
Online Converters
There are quite a few only converters e.g.
https://www.tablesgenerator.com/markdown_tables
but beware: when dealing with sensitive company data you might want to avoid these!
IDE integration
For Visual Studio Code there is a neat extension:
https://marketplace.visualstudio.com/items?itemName=csholmq.excel-to-markdown-table
Some Python
Another way is to use pandas to take care of the conversion:
import pandas as pd
df = pd.read_excel('test.xlsx')
md_table = df.to_markdown(index=False)
with open("test.md", "w") as f:
f.write(md_table)
When we are dealing with multiple sheets inside our excel document we can do the following:
sheet_names = pd.ExcelFile('test.xlsx').sheet_names
for sheet in sheet_names:
df = pd.read_excel('test.xlsx', sheet)
md_table = df.to_markdown(index=False)
print(md_table)
with open(f"test_{sheet}.md", "w") as f:
f.write(md_table)