Python plugin for Gnumeric spreadsheet
Harry G. George
hgg9140 at skewer.ca.boeing.com
Wed Feb 23 12:40:11 EST 2000
Not necessarily the best way, but possible:
#determine value from analyzing cbool
#---load the data---
if p() and not q() and r() and not s():
print "test ok"
print "test fails"
#---report it back out---
Jon K Hellan <hellan at acm.org> writes:
> I am looking for suggestions.
> The Gnumeric spreadsheet has a plugin which lets you define
> spreadsheet functions in Python. General scripting of the spreadsheet
> is not (yet?) supported.
> To give you an idea, here is how a very simple function is defined in
> Python and made available to Gnumeric:
> import gnumeric
> # Function definition
> def mid(text,start_num,num_chars):
> return text[start_num-1:start_num+num_chars-1];
> # Help text for Gnumeric
> help_mid = \
> "@FUNCTION=MID\n" \
> "@SYNTAX=MID(text,start,num_chars)\n" \
> "@DESCRIPTION=" \
> "Returns a specific number of characters from a text string, " \
> "starting at START and spawning NUM_CHARS. Index is counted " \
> "starting from one"
> # register_function is a C function in Gnumeric to - you guessed it -
> # register the function. The parameters are:
> # - function name
> # - parameter types
> # - paremeter names - for use in the function wizard
> # - help string
> # - python function
> gnumeric.register_function ("mid", "sff", "text, start_num, num_chars",
> help_mid, mid);
> The plugin doesn't yet handle booleans properly. Python is happy to
> consider 0 or None false, and everything else true. But inside
> Gnumeric, booleans are a distinct datatype. A function defined in
> Python may receive a boolean from a C function, and will want to
> return it to the spreadsheet without converting to integer. So a
> distinguished boolean datatype is needed.
> What is the most pythonesque way to do that?
> I forgot to mention. Gnumeric tries to be compatible with Excel.
> Who can help?
Harry George E-mail: harry.g.george at boeing.com
The Boeing Company Renton: (425) 237-6915
P. O. Box 3707 OY-89 Everett: (425) 266-3149
Seattle, WA 98124-2207 Page: (425) 631-8803
More information about the Python-list