Commit 0c0cb7bf authored by Morten Welinder's avatar Morten Welinder

Introspection fixes

parent 8af29054
...@@ -657,6 +657,12 @@ parsepos_as_string (GnmParsePos const *pp) ...@@ -657,6 +657,12 @@ parsepos_as_string (GnmParsePos const *pp)
pp->sheet && pp->sheet->convs->r1c1_addresses); pp->sheet && pp->sheet->convs->r1c1_addresses);
} }
/**
* cell_name:
* @cell: #GnmCell
*
* Returns: (transfer none): the name of @cell, like "B11"
*/
char const * char const *
cell_name (GnmCell const *cell) cell_name (GnmCell const *cell)
{ {
......
...@@ -3891,7 +3891,7 @@ cell_ordering (gconstpointer a_, gconstpointer b_) ...@@ -3891,7 +3891,7 @@ cell_ordering (gconstpointer a_, gconstpointer b_)
/** /**
* sheet_cells: * sheet_cells:
* @sheet: a #Sheet * @sheet: a #Sheet
* @r: a #GnmRange * @r: (nullable): a #GnmRange
* *
* Retrieves an array of all cells inside @r. * Retrieves an array of all cells inside @r.
* Returns: (element-type GnmCell) (transfer container): the cells array. * Returns: (element-type GnmCell) (transfer container): the cells array.
......
...@@ -14,7 +14,10 @@ my $ref = join("",<DATA>); ...@@ -14,7 +14,10 @@ my $ref = join("",<DATA>);
sub { $_ eq $ref }); sub { $_ eq $ref });
__DATA__ __DATA__
Peek: Number of columns: 256
Number of rows: 65536
As string:
10 10
101.25 101.25
111.25 111.25
...@@ -31,3 +34,12 @@ As int: ...@@ -31,3 +34,12 @@ As int:
0 0
0 0
1 1
List of cells in sheet:
A1
A2
A3
A4
A5
A6
A7
...@@ -6,8 +6,16 @@ gi.require_version('Gnm', '1.12') ...@@ -6,8 +6,16 @@ gi.require_version('Gnm', '1.12')
from gi.repository import Gnm from gi.repository import Gnm
Gnm.init() Gnm.init()
# Create a workbook with one sheet
wb = Gnm.Workbook.new_with_sheets(1) wb = Gnm.Workbook.new_with_sheets(1)
# Get sheet. Index starts at 0
sheet = wb.sheet_by_index(0) sheet = wb.sheet_by_index(0)
print "Number of columns:", sheet.get_size().max_cols
print "Number of rows:", sheet.get_size().max_rows
# Store values and expressions is some cells. Coordinates are (col,row)
# both starting at 0. (So what the gui sees as row 1 is 0 here.)
sheet.cell_set_value(0,0,Gnm.Value.new_int(10)) sheet.cell_set_value(0,0,Gnm.Value.new_int(10))
sheet.cell_set_value(0,1,Gnm.Value.new_float(101.25)) sheet.cell_set_value(0,1,Gnm.Value.new_float(101.25))
sheet.cell_set_text(0,2,"=A1+A2") sheet.cell_set_text(0,2,"=A1+A2")
...@@ -15,12 +23,18 @@ sheet.cell_set_text(0,3,"'01") ...@@ -15,12 +23,18 @@ sheet.cell_set_text(0,3,"'01")
sheet.cell_set_text(0,4,"zzz") sheet.cell_set_text(0,4,"zzz")
sheet.cell_set_value(0,5,Gnm.Value.new_string("abc")) sheet.cell_set_value(0,5,Gnm.Value.new_string("abc"))
sheet.cell_set_value(0,6,Gnm.Value.new_bool(1)) sheet.cell_set_value(0,6,Gnm.Value.new_bool(1))
# Recalculate all cells that need it
wb.recalc() wb.recalc()
print "Peek:" print "\nAs string:"
for i in range(7): for i in range(7):
print sheet.cell_get_value(0,i).peek_string() print sheet.cell_get_value(0,i).get_as_string()
print "\nAs int:" print "\nAs int:"
for i in range(7): for i in range(7):
print sheet.cell_get_value(0,i).get_as_int() print sheet.cell_get_value(0,i).get_as_int()
print "\nList of cells in sheet:"
for c in sheet.cells(None):
print c.name()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment