Using prettytables with Pluto

pretty_table(HTML, …) looks much nicer in Pluto than pretty_table(…) which (I think) defaults to the text backend. However, unlike the text backend, pretty_table(HTML,…) shows the entire table rather than having a vertical scrollbar for tables with many rows. Is there an override for this default, i.e. can one have the better looking display of the HTML backend and still have a scrollable display?

for others who are interested in this: i found a way but it’s ugly. i’m hoping someone can point out an argument to pretty_table that i’m unaware of.

here’s my ugly solution for pretty printing dataframe df in Pluto:

using HypertextLiteral, PrettyTables
html_table = pretty_table(String, df, backend = Val(:html),formatters =...)
scrollable_table = @htl("""
    <div style="max-height: 400px; overflow-y: auto; border: 1px solid #ccc;">
        $(HTML(html_table))
    </div>
""")
scrollable_table

as a further addendum: it would be great to have the column headers remain visible while scrolling down in either the text or html backends. is that possible?

1 Like