The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Automation Server/COM and LabVIEW
 Sending data to worksheet (Python)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cjguthrie3

2 Posts

Posted - 07/19/2017 :  12:34:19 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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)
Go to Top of Page

YimingChen

1606 Posts

Posted - 08/30/2017 :  5:52:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000