# populate the table : for i in range(10): table.set_value((1, i), (i + 1)**2) table.set_value("A11", "Total:") # lets define a named range for the 10 values : crange = "B1:B10" name = "squares_values" table_name = table.name table.set_named_range(name, crange, table_name) # we can define a single cell range, using notation "B11" or (1, 10) : table.set_named_range('total', (1, 10), table_name) # get named range values : values = table.get_named_range('squares_values').get_values(flat=True) # set named range value : result = sum(values) table.get_named_range('total').set_value(result) # lets use the named ranges from a second table : table2 = Table("Second Table") body.append(table2) named_range1 = table2.get_named_range('total') table2.set_value('A1', "name:") table2.set_value('B1', named_range1.name) table2.set_value('A2', "range:") table2.set_value('B2', str(named_range1.crange)) table2.set_value('A3', "from table:")
# populate the table : for i in range(10): table.set_value((1, i), (i + 1)**2) table.set_value("A11", "Total:") # lets define a named range for the 10 values : crange = "B1:B10" name = "squares_values" table_name = table.name table.set_named_range(name, crange, table_name) # we can define a single cell range, using notation "B11" or (1, 10) : table.set_named_range("total", (1, 10), table_name) # get named range values : values = table.get_named_range("squares_values").get_values(flat=True) # set named range value : result = sum(values) table.get_named_range("total").set_value(result) # lets use the named ranges from a second table : table2 = Table("Second Table") body.append(table2) named_range1 = table2.get_named_range("total") table2.set_value("A1", "name:") table2.set_value("B1", named_range1.name) table2.set_value("A2", "range:") table2.set_value("B2", str(named_range1.crange)) table2.set_value("A3", "from table:")