I don’t know how to over came this problem the validity list doesn’t put the list in the drop down to choose.
The code is this:
#!/usr/bin/python3
#-*-coding:utf8-*-
import uno
def CalcExamples():
desktop=XSCRIPTCONTEXT.getDesktop()
model=desktop.getCurrentComponent()
if not hasattr(model, "Sheets"):
model=desktop.loadComponentFromURL("private:factory/scalc", "_blank",
0, ())
sheets=model.Sheets.getByIndex(0)
#Validity list
dv_list1 = sheets.getCellRangeByName("B2")
oValidation1 = dv_list.Validation
oValidation1.Type = "LIST"
oValidation1.setFormula1('"PEAD";"PEX"')
dv_list1.Validation = oValidation1
#Choose diferences from PEAD and PEX
dv_list2 = sheets.getCellRangeByName("C2")
oValidation2 = dv_list.Validation
oValidation2.Type = "LIST"
oValidation2.setFormula1('=IF($Sheets.$B$2="PEAD";"1,0 MPa";IF($Sheets.$B$2="PEX";'"1,25 MPa";"2,0 MPa"';"Escolha!"))')
dv_list2.Validation = oValidation2
#I've tried this as well
#oValidation2.setFormula1('=IF($Sheets.$B$2="PEAD";"1,0 MPa";IF($Sheets.$B$2="PEX";{"1,25 MPa";"2,0 MPa"};"Escolha!"))')
return None
g_exportedScripts = CalcExamples,