Introspection fixes
[gnumeric.git] / test / t3001-introspection-simple.py
blobe6c2204742dcf474c9b684c5bba4e118c734df98
1 #!/usr/bin/python
2 # -----------------------------------------------------------------------------
4 import gi
5 gi.require_version('Gnm', '1.12')
6 from gi.repository import Gnm
7 Gnm.init()
9 # Create a workbook with one sheet
10 wb = Gnm.Workbook.new_with_sheets(1)
12 # Get sheet. Index starts at 0
13 sheet = wb.sheet_by_index(0)
14 print "Number of columns:", sheet.get_size().max_cols
15 print "Number of rows:", sheet.get_size().max_rows
17 # Store values and expressions is some cells. Coordinates are (col,row)
18 # both starting at 0. (So what the gui sees as row 1 is 0 here.)
19 sheet.cell_set_value(0,0,Gnm.Value.new_int(10))
20 sheet.cell_set_value(0,1,Gnm.Value.new_float(101.25))
21 sheet.cell_set_text(0,2,"=A1+A2")
22 sheet.cell_set_text(0,3,"'01")
23 sheet.cell_set_text(0,4,"zzz")
24 sheet.cell_set_value(0,5,Gnm.Value.new_string("abc"))
25 sheet.cell_set_value(0,6,Gnm.Value.new_bool(1))
27 # Recalculate all cells that need it
28 wb.recalc()
30 print "\nAs string:"
31 for i in range(7):
32 print sheet.cell_get_value(0,i).get_as_string()
34 print "\nAs int:"
35 for i in range(7):
36 print sheet.cell_get_value(0,i).get_as_int()
38 print "\nList of cells in sheet:"
39 for c in sheet.cells(None):
40 print c.name()