LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i copy data from excel into labview

I have a spreadsheet with some data in excel.  What i need to do is be able to straight copy then paste it into a labview table control but whenever i try to do this it just puts all the data into the first cell on the table control in labview.  is there a table control that will allow for the correct copying of the data from excel?
 
thanks
Brent
0 Kudos
Message 1 of 7
(5,488 Views)
When you read the data from Excel you read it as a variant. You had to cast it to the appropriate datatype using the Variant To Data function. What are you casting it to? Attached is an example I wrote a while ago for reading Excel data into a string array. The string array can be replaced with a table, as it's the same datatype.

You may also want to peruse the Excel thread.
0 Kudos
Message 2 of 7
(5,482 Views)
I will peruse that board you forwarded me to but what i'm intending is for the user to open a sheet in excel, select the cells he needs and then hitting ctrl+c and then going into the labview program and selecting a cell in the table and hitting ctrl+v to paste the cells into the table control.  thanks for the prompt response as well!
 
Brent
0 Kudos
Message 3 of 7
(5,474 Views)

Hi Brent,

I'm afraid I don't believe this is possible directly but there may be a work around by copying into a string control and then using spreadsheet string to array although I have not managed to get this working yet!

I let you know if I have any luck.

Regards,

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
0 Kudos
Message 4 of 7
(5,463 Views)
To do what you want you basically have to access the clipboard programmatically. You won't be able to do it in an automatic way using Ctrl-V. Basically you have to provide a means to the user to initiate the pasting, and have the program read the data from the clipboard and convert it to a string array. An example can be found here. It's a little old, so you will likely need to update/modify it for the newer version of LabVIEW.
Message 5 of 7
(5,457 Views)
Just like James mentioned, I also don't know if it is directly possible.  Here might be a work around.  The user selects the cells, presses a macro button in excel. The macro does a
Selection.Copy
Sheets("Sheet2").Select
Range("A1").Select
ActiveSheet.Paste

Then do a file save as, save as a csv to a known temp file.  The user presses a button in LabVIEW that reads from the temp file.

From there on, it is in LabVIEW.  It's a bit longer approach, but it might work for you.
0 Kudos
Message 6 of 7
(5,456 Views)

I have quickly checked out that copypaste example and that looks like ill be able to use it.  at least the get text from clipboard and maybe the copy to table as well.  ill see what i can do and report back on how i got it accomplished

 

thanks guys

0 Kudos
Message 7 of 7
(5,436 Views)