# Is there a way to compile interactive tables into an HTML book in Julia?

**URL:** https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533
**Category:** Tooling
**Tags:** question
**Created:** [January 31, 2022, 7:37pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533 "2022-01-31T19:37:28Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [January 31, 2022, 7:37pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/1 "2022-01-31T19:37:29Z")

</div>

My lab uses HTML notebooks to communicate information to stakeholders.

I am curious about migrating my workflow from R to Julia but am having trouble replicating an interactive table that I can include in the book like `DT` + `bookdown` in R or `itables` + `jupyter-book` in Python.

I’ve tried using ipynbs and making an R or Python call via `RCall` or `PyCall` just for the corresponding table function I need but the table isn’t displayed (I am assuming there a is a type issue here). What I tried:

## PyCall

```using

py"""

# example from the docs
import itables 
import pandas as pd
import numpy as np

df = pd.DataFrame({
    'cups_of_coffee': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
    'productivity': [2, 5, 6, 8, 9, 8, 0, 1, 0, -1]
})

itables.show(df)

"""py

```

This was probably a naive experiment and doesn’t return or display anything in the book.

## RCall

```julia-auto
using RCall

R"

library(DT)
x <- datatable(mtcars)
"
# this gives me an ordered dict of the dataset (fair enough!)
@rget x

```

## `TableView.jl`

I’ve also tried `TableView.jl` which works great when I’m using the live Jupyter Lab interface…

```julia-auto
using RDatasets
using TableView

# great!
mtcars = dataset("datasets", "mtcars");

```

…but doesn’t appear in the finished book when I compile to `jupyter-book`. It gives an error about not detecting the required extension in the environment (again, only when building the book):

```julia-auto
WebIO not detected.

Please read the troubleshooting guide for more information on how to resolve this issue.

https://juliagizmos.github.io/WebIO.jl/latest/troubleshooting/not-detected/

```

This suggests perhaps I could resolve the issue by including the extension in the compilation environment somehow, but before I spent a bunch more time on it I wanted to make sure I hadn’t overlooked an existing solution.

Are there solutions I’m missing, and, if not, what are some steps I might try to get an interactive table compiled into an HTML book?

EDIT: typo and…  
NOTE: the issue with `TableView.jl` happens when I use `jupyter-book` and `weave.jl`, so I am guessing it’s just not designed with this in mind.

---

<div class="post-metadata">

### Author: ![TheCedarPrince](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/thecedarprince/32/17323_2.png) [@TheCedarPrince](https://discourse.julialang.org/u/TheCedarPrince)
#### Post date: [January 31, 2022, 7:53pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/2 "2022-01-31T19:53:09Z")

</div>

Maybe Books.jl might be what you are looking for? [https://github.com/JuliaBooks/Books.jl](https://github.com/JuliaBooks/Books.jl)

@rikh would certainly know more about it than I.

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [January 31, 2022, 7:55pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/3 "2022-01-31T19:55:29Z")

</div>

Thank you! This looks like the right idea, I’ll give it a test!

---

<div class="post-metadata">

### Author: ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)
#### Post date: [January 31, 2022, 8:13pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/4 "2022-01-31T20:13:09Z")

</div>

Interactive tables are not in Books.jl and I also suspect that you’re more into single page conversions which is not a focus of Books.jl

PlutoSliderServer has some more dynamic capabilities. Or what does an “interactive table” mean? Is it an HTML table with a bunch of Javascript on top (static) or does it also require a server?

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [January 31, 2022, 8:32pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/5 "2022-01-31T20:32:24Z")

</div>

Thanks!

In terms of what I need to be able to replicate to leave R, it would be a table my end users can filter and search like those made by [DT](https://rstudio.github.io/DT/) or [itables](https://mwouts.github.io/itables/quick_start.html).

And they’re an HTML table with a bunch of JS on top. They are compiled into the HTML book and and do not require a server (though we host the books centrally to avoid having more than one version of the truth if the reports are updated).

---

<div class="post-metadata">

### Author: ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)
#### Post date: [January 31, 2022, 8:40pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/6 "2022-01-31T20:40:43Z")

</div>

I’m 99% sure that the news unfortunately is that such things packages aren’t available in Julia at this moment.

> [@WileyQuixotey](#):
>
> Are there solutions I’m missing, and, if not, what are some steps I might try to get an interactive table compiled into an HTML book?

I don’t have much experience with your particular problem, but I do know that sometimes when language wrappers do not work then there is luckily CSV, that is, store CSV in Julia and read it with R or vice versa.

---

<div class="post-metadata">

### Author: ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)
#### Post date: [January 31, 2022, 8:50pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/7 "2022-01-31T20:50:38Z")

</div>

Does [TableView](https://github.com/JuliaComputing/TableView.jl) do what you are asking for?

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [January 31, 2022, 8:57pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/9 "2022-01-31T20:57:41Z")

</div>

Ok, I’ll see if there is workaround with the intermediaries that works for now. It might also be worth asking some of the other authors how I might go about it if I was going to attempt to write something that would be compatible with existing tools.

Thanks for your time! 🙂

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [January 31, 2022, 9:00pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/10 "2022-01-31T21:00:58Z")

</div>

Unfortunately, no - that’s the example that doesn’t end up in the book. It does seem like it’s the closest so I’ll see if I can fix the issue with the compilation environment.

---

<div class="post-metadata">

### Author: ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)
#### Post date: [February 1, 2022, 4:36pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/11 "2022-02-01T16:36:10Z")

</div>

I’ve been playing with it and…frustration. When I load the notebook file and execute it interactively, it’s fine, but when you export or nbconvert to html, it no longer can see the webio notebook extension that TableView needs.

---

<div class="post-metadata">

### Author: ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)
#### Post date: [February 1, 2022, 5:48pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/12 "2022-02-01T17:48:43Z")

</div>

Maybe have a look at [quarto](https://quarto.org/), it’s a brilliant system for converting Markdown and notebooks (including IJulia notebooks) to different formats. It’s done by the RStudio people based on pandoc (like Bookdown I think). You can execute Julia code using notebooks, or with code blocks in Markdown files.

I don’t know if it does what you need, but it’s worth having a look at the project anyway 🙂

---

<div class="post-metadata">

### Author: ![DoktorMike](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doktormike/32/2736_2.png) [@DoktorMike](https://discourse.julialang.org/u/DoktorMike)
#### Post date: [February 1, 2022, 7:16pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/13 "2022-02-01T19:16:45Z")

</div>

That’s awesome! Long time user of RMarkdown here and what a happy journey it’s been. This looks like the next level to me and i look forward to creating new reports based on julia code as well.

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [February 1, 2022, 7:26pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/14 "2022-02-01T19:26:13Z")

</div>

Same! I’ve documented my efforts [here](https://github.com/thadryanjs/migrate-to-jupyter/tree/master/testbook).

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [February 1, 2022, 7:27pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/15 "2022-02-01T19:27:43Z")

</div>

Thanks for bringing this to my attention I will def take a peek!

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [February 1, 2022, 10:34pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/16 "2022-02-01T22:34:23Z")

</div>

I am infuriatingly close. I am using `RCall` to generate a beautiful table in a standalone HTML file:

```julia
using RDatasets
using RCall

x = dataset("datasets", "mtcars");

@rput x;

R"

library(DT)

htmlwidgets::saveWidget(x %>% DT::datatable(.), 'result.html')

"

```

Thus, a more refined version of my question is “In `ipynb`, does anyone know how I can get a markdown cell or a Julia cell to display this HTML file?”

`WebIO` is out, I get the same thing from before in the books, I just recreate it myself:

```julia
using WebIO

htmlString = read("result.html", String)

Scope(dom=node(:p, htmlString))

```

Looks like I should ask the `WebIO` folks about this.

At least now I can take the partial victory of knowing I can likely get this to work by switching back to `Rmd` where I’d have cells-by-language or switch to Python where I’d have magics instead of calls from a library.

I might not be able to escape to Julia but I do now know I can at least escape to Python lol.

---

<div class="post-metadata">

### Author: ![tobydriscoll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tobydriscoll/32/1843_2.png) [@tobydriscoll](https://discourse.julialang.org/u/tobydriscoll)
#### Post date: [February 3, 2022, 2:48pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/17 "2022-02-03T14:48:28Z")

</div>

> [@WileyQuixotey](#):
>
> I might not be able to escape to Julia but I do now know I can at least escape to Python lol.

Kind of like escaping from Pepsi to Coke instead of Prosecco. 😆

You could avoid the R part by writing a translator to client-side HTML/JS, like [Tabulator](http://tabulator.info), which does not look difficult. I still don’t see how to inject that into a jupyter-book or weave page, but you could write a script to post-process the initial HTML outputs.

---

<div class="post-metadata">

### Author: ![WileyQuixotey](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wileyquixotey/32/33394_2.png) [@WileyQuixotey](https://discourse.julialang.org/u/WileyQuixotey)
#### Post date: [February 3, 2022, 8:54pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-compile-interactive-tables-into-an-html-book-in-julia/75533/18 "2022-02-03T20:54:29Z")

</div>

> [@tobydriscoll](#):
>
> Kind of like escaping from Pepsi to Coke instead of Prosecco

LMAO that’s good. I’d much prefer to be working in Python over R so to me it’s more like escaping from Diet Pepsi to a PBR when I was looking for a Boston Lager lol.

I will look into this other angle and open a question issue on WebIO. Thanks all!
