Hello!
What I want to do:
- Let the user import an Excel file
- Extract the available worksheets
- List them in the Python part, where the user can select the worksheets that he wants to work with (each worksheet has a checkbox)
My problem: I am successfully allowing the user to import the file and retrieve the worksheets, but I am not able to list all the worksheets.
Right now I am trying to do it like this:
Creating the parameter:
<Parameter>
<Name>SelectedWorksheets</Name>
<Text>Worksheet1,Worksheet2</Text>
<Value>False|False</Value>
<ValueType>namedtuple(CheckBox,CheckBox)</ValueType>
<NamedTuple>
<TypeName>WorksheetSelection</TypeName>
<FieldNames>Worksheet1,Worksheet2</FieldNames>
</NamedTuple>
</Parameter>
Modifying the parameter:
props = ctrl_prop_util.control_props
# Assigning worksheet names to props[':SelectedWorksheets'][0].text
props[':SelectedWorksheets'][0].text = '|'.join(worksheet_names)
But when I try to change the value string, I get the error that value_str does not have any setters. This is how I am trying to change it:
props[':SelectedWorksheets'][0].value_str = '|'.join(['False'] * len(worksheet_names))
Is there another way to do this?
Another option would be to dynamically create the parameter (creating a checkbox parameter for each worksheet), but I did not manage to do this and I also could not find anything in the manual...