Wednesday 30 December 2020

embed plotly in excel

i'm trying to embed an interactive plotly (or bokeh) plot into excel.

To do this I've tried:

  1. embed a Microsoft Web Browser UserForm into excel, following:

How do I embed a browser in an Excel VBA form?

This works and enables both online and offline html to be loaded

  1. creating a plotly html

'''

import plotly
import plotly.graph_objects as go


x = [0.1, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0]
y = [i**2 for i in x]

fig = go.Figure()

fig.add_trace(go.Scatter(x=x, y=x, mode='markers', name="y=x", marker=dict(color='royalblue', size=8)))
fig.add_trace(go.Scatter(x=x, y=y, name="y=x^2", line=dict(width=3)))

plotly.offline.plot(fig, filename='C:/Users/.../pythonProject/test1.html')
  1. repointing the webbrowser object in excel using .Navigate to the local plotly.html. Banner pops up with

".... restricted this file from showing active content that could access your computer"

clicking on the banner, i run into this error:

enter image description here

The same HTML can be opened in a browser.

Anyway to show interactive plots in excel?

Many thanks,

dusio



from embed plotly in excel

No comments:

Post a Comment