Register new function

Function example
Users can create new functions and use them, functions get a string that contain the arguments and return a string that represent the function result. All functions except arguments that can evaluate to float and return strings that can evaluate to float.

One argument example
Example of a function that get one argument

from simpleodspy.sodsspreadsheet import SodsSpreadSheet
from simpleodspy.sodshtml import SodsHtml
 
t = SodsSpreadSheet()
 
def mul3Callback(arg):
	val = t.evaluateFormula(arg) * 3 
	return str(val)
 
t.registerFunction('MUL3', mul3Callback)
 
t.setValue("D2", 123.5)
t.setValue("D3", "=3.0/5.0")
t.setValue("D4", "=MUL3(D2+D3)")
 
tw = SodsHtml(t)
tw.save("test.html")

List argument example
Example of a function that get one List

from simpleodspy.sodsspreadsheet import SodsSpreadSheet
from simpleodspy.sodshtml import SodsHtml
 
t = SodsSpreadSheet()
 
def mulListCallback(cell_range):
	val = 1
	for arg in t.rangeIterator(cell_range): 
		val *= t.evaluateFormula(arg)
 
	return str(val)
 
t.registerFunction('MUL_LIST', mulListCallback)
 
t.setValue("D2", 123.5)
t.setValue("D3", "=3.0/5.0")
t.setValue("D4", "=MUL_LIST(D2:D3)")
 
tw = SodsHtml(t)
tw.save("test.html")