flex_subtitle = "built using jupyter-flex"
flex_external_link = "https://github.com/danielfrg/jupyter-flex/blob/master/examples/widgets/ipysheet.ipynb"
flex_orientation = "rows"
flex_show_source = True
import ipysheet
sheet = ipysheet.sheet(rows=3, columns=4)
cell1 = ipysheet.cell(0, 0, 'Hello')
cell2 = ipysheet.cell(2, 0, 'World')
cell_value = ipysheet.cell(2,2, 42.)
sheet
sheet = ipysheet.sheet(rows=5, columns=4)
row = ipysheet.row(0, [0, 1, 2, 3], background_color="red")
column = ipysheet.column(1, ["a", "b", "c", "d"], row_start=1, background_color="green")
cells = ipysheet.cell_range([["hi", "ola"], ["ciao", "bonjour"], ["hallo", "guten tag"]],
row_start=1, column_start=2, background_color="yellow")
sheet
import ipywidgets as widgets
sheet = ipysheet.sheet(rows=3, columns=2, column_headers=False, row_headers=False)
cell_a = ipysheet.cell(0, 1, 1, label_left='a')
cell_b = ipysheet.cell(1, 1, 2, label_left='b')
cell_sum = ipysheet.cell(2, 1, 3, label_left='sum', read_only=True)
# create a slider linked to cell a
slider = widgets.FloatSlider(min=-10, max=10, description='a')
widgets.jslink((cell_a, 'value'), (slider, 'value'))
# changes in a or b should trigger this function
def calculate(change):
cell_sum.value = cell_a.value + cell_b.value
cell_a.observe(calculate, 'value')
cell_b.observe(calculate, 'value')
widgets.VBox([sheet, slider])
import ipywidgets as widgets
sheet_2 = ipysheet.sheet(rows=3, columns=2, column_headers=False, row_headers=False)
cell_a_2 = ipysheet.cell(0, 1, 1, label_left='a')
cell_b_2 = ipysheet.cell(1, 1, 2, label_left='b')
cell_sum_2 = ipysheet.cell(2, 1, 3, label_left='sum', read_only=True)
# create a slider linked to cell a
slider_2 = widgets.FloatSlider(min=-10, max=10, description='a')
widgets.jslink((cell_a_2, 'value'), (slider_2, 'value'))
@ipysheet.calculation(inputs=[cell_a_2, cell_b_2], output=cell_sum_2)
def calculate(a, b):
return a * b
widgets.VBox([sheet_2, slider_2])