Paste clipboard into a table

Hi

I want to paste data from excel in a table but I can’t write to the table
I found different script in the forum http://www.inductiveautomation.com/forum/viewtopic.php?f=23&t=3762, its works but I would like copy the data in excel and paste in a table in Ignition
I modify the script but it doesn’t work

Thank you for your help.
Nadya

I found to paste one row from excel into the table
but I can’t paste all rows

def doPaste(event):
from java.awt import Toolkit
import system
from java.awt.datatransfer import DataFlavor
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
contents = clipboard.getContents(None).getTransferData(DataFlavor.stringFlavor)
print contents
headers = [“Tag name type”,“DataType”,“OPCServer”,“OPCItemPath”,“HistoryEnabled”,“PrimaryHistoryProvider”,“HistoricalScanclass”,“HistoricalDeadband”]
data=[]
text = contents
line = text.split("\t")
print line
word = line
#print word
# Add the list as a row of data for our table
data.append(word)
event.source.parent.getComponent(‘Table’).data=system.dataset.toDataSet(headers,data)

Tks

I found it’s easy

def doPaste(event):
from java.awt import Toolkit
import system
from java.awt.datatransfer import DataFlavor
clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()
contents = clipboard.getContents(None).getTransferData(DataFlavor.stringFlavor)
#print contents
headers = [“Tag name type”,“DataType”,“OPCServer”,“OPCItemPath”,“HistoryEnabled”,“PrimaryHistoryProvider”,“HistoricalScanclass”,“HistoricalDeadband”]
data=[]
text = contents
print text
col = text.split("\n")
for i in col:
if len(i)!=0 :
line = i.split("\t")
print line
data.append(line)
event.source.parent.getComponent(‘Table’).data=system.dataset.toDataSet(headers,data)

2 Likes

hi, im trying to use this script. can you please let me know where you put this in order to get it to work from Excel.

i want to past multiple rows into a dataset from Excel