Hello,
there seems to be an issue with the add_sheet(..) method on WBooks.
I've tried to add a new sheet to an existing Workbook and ended with the same error in python every time. This is my code (simplified):
import originpro as op
po = op.po
po.Visible = 1
x_vals = [1,2,3,4,5,6,7,8,9,10]
y_vals = [23,45,78,133,178,199,234,278,341,400]
wks = op.new_sheet('w', 'First Dataset')
#
wks.name = 'Long Sheet Name'
wks.from_list(0, x_vals, 'X Values')
wks.from_list(1, y_vals, 'Y Values')
#
wks2 = op.new_sheet('w', '2nd Dataset')
wks2.name='Long Name of 2nd Sheet'
wks2.from_list(0, x_vals, 'X')
wks2.from_list(1, y_vals, 'Y')
wks3 = wks2.get_book().add_sheet('Additional Sheet on 2nd Dataset', active=True)
After code execution all Sheets are created as intended but the last one is not 'active'.
Python returns this error message:
quote:
RuntimeError: Exception in OriginExt OriginObject::SetNumProp
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/Users/xxxxxxxxxx/PycharmProjects/OriginConnection/main.py", line 20, in <module>
wks3 = wks2.get_book().add_sheet('Additional Sheet on 2nd Dataset', active=True)
File "C:\Users\xxxxxxxxxx\.conda\envs\origin\lib\site-packages\originpro\worksheet.py", line 710, in add_sheet
return WSheet(self._add_sheet(name, active))
File "C:\Users\xxxxxxxxxx\.conda\envs\origin\lib\site-packages\originpro\base.py", line 196, in _add_sheet
self.set_int("active", obj1.GetIndex()+1)
File "C:\Users\xxxxxxxxxx\.conda\envs\origin\lib\site-packages\originpro\base.py", line 40, in set_int
self.obj.SetNumProp(prop, int(value))
File "C:\Users\xxxxxxxxxx\.conda\envs\origin\lib\site-packages\OriginExt\OriginExt.py", line 715, in SetNumProp
return _OriginExt.OriginObject_SetNumProp(self, strVarName, dVal)
SystemError: <built-in function OriginObject_SetNumProp> returned a result with an error set
I'm working with Python 3.7.9 and Origin 9.7.5.184.
Can anyone confirm this behavior?