Author |
Topic |
|
cjguthrie3
2 Posts |
Posted - 07/19/2017 : 12:34:19 PM
|
I have previously used MATLAB to send data to a worksheet using the command:
worksheet.SetData(data,0,0)
Where data is a cell array of numbers and strings.
Now I'm trying to port my code to python, but this command doesn't seem to work. I keep getting this error:
com_error: (-2147352567, 'Exception occurred.', (8177, u'Origin 2016', u'Origin COM Error, argument 1 invalid!', None, 0, 0), None)
This time, I have just made data a simple list of lists, as per this example http://www.originlab.com/doc/python: data =[[x for x in range(5)] for x in range(5)]
Any thoughts on why this command doesn't work in python? Note: I am able to do just about everything else. I can open up origin, make workbooks, worksheets, and graphs, etc.
Origin Ver. and Service Release (Select Help-->About Origin): Origin 2016 (64-bit) Operating System: Windows 10 |
|
cjguthrie3
2 Posts |
Posted - 07/19/2017 : 1:02:33 PM
|
This is my entire code, if it is helpful:
origin = win32com.client.Dispatch("Origin.ApplicationSI") origin.Visible=1 origin.Execute("sec -poc 3.5") workbookName = origin.CreatePage(2, 'Test' , 'Origin') workbook = origin.WorksheetPages(workbookName) worksheet = workbook.Layers(0) worksheet.Cols = 5 data =[[x for x in range(5)] for x in range(5)] worksheet.SetData(data,0,0) |
|
|
YimingChen
1606 Posts |
Posted - 08/30/2017 : 5:52:44 PM
|
Hi,
We tested your code and can reproduce the error in Origin 2016,2017. But the code works in the upcoming new release 2018. We will look into it for now. In the meantime, you can simply replace the line worksheet.SetData(data,0,0) with origin.PutWorksheet(workbookName,data,0,0), which should import your data properly. Hope this answers your question. Thank you.
Yiming |
|
|
|
Topic |
|
|
|