The Origin Forum
File Exchange
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Automation Server/COM and LabVIEW
 Sending data to worksheet (Python)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
   

T O P I C    R E V I E W
cjguthrie3 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
2   L A T E S T    R E P L I E S    (Newest First)
YimingChen 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
cjguthrie3 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)

The Origin Forum © 2008 Originlab Corporation Go To Top Of Page
Snitz Forums 2000