Exporte la liste des tableaux et des colonnes d’un classeur au format ErDiagram (Schéma Relation Entité) de Mermaid, utilisable dans github.
![](https://www.fxparlant.net/wp-content/uploads/2023/04/screen_20230405_191037.png)
Sub exportMermaid()
Debug.Print "erDiagram"
For Each sh In ActiveWorkbook.Sheets
For Each tb In sh.ListObjects
Debug.Print tb.Name & "{"
For Each col In tb.ListColumns
If col.Range(1) = 1 Then clé = "PK" Else clé = ""
If IsDate(col.Range(1)) Then
col_type = "date"
ElseIf IsNumeric(col.Range(1)) Then
col_type = "numeric"
Else
col_type = "string"
End If
Debug.Print col_type & " " & col.Name & clé
Next col
Debug.Print "}"
Next tb
Next sh
End Sub
Permet d’obtenir le code à placer entre les div class= »mermaid » dans un html ou un md:
<div class="mermaid">
erDiagram
livre ||--o{ auteur : ecrit
livre {
int id PK
string titre
string isbn
int auteur FK
}
auteur {
int id PK
string nom
string prenom
}
</div>