LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview to excel

Solved!
Go to solution

Hi everyone,

I am quite new to labview and I was thinking of how I can make a project that will write to excel from labview. I do not want to write an entire string, rather when I receive a name and values, I want to search in the file for that name and add the values in. So if I have a file with the following format,

Country Name Age Height

Canada    x

US           y

 

And if I send a command like (X, 19, 70)

 

The file should be changed to 

Country Name Age Height

Canada    x        19      70

US           y

 

That is my first option. I was also thinking that if the first option is too hard to achieve, I could also have something like 

Country Name Age Height

And send command like (Canada, X, 19, 70), and append data to the file. So for each time, I have to concatenate the string with unnecessary values but that could make my life easier. 

 

I am quite new to labview and I do not have a vi to show. My project is still in the designing phase in my mind. I do not want to use any AcitveX or report toolkit. I am using labview 8.0 in windows 10. Any help is greatly appreciated.

 

Thanks,

Kaawn

0 Kudos
Message 1 of 7
(4,591 Views)
Solution
Accepted by kaawn

First off, you mean a spreadsheet file and not an actual MS Excel (.xlsx) file right?  A lot of people use the terms interchangeably but they are not the same thing at all so it's best to be clear.

 

For a simple spreadsheet application either of your options is very easy to achieve with  Read and Write Delimited Spreadsheet and the basic string and array VIs.

 

Basically you will read the whole file into an array.

Process the data in the array.

Write the new array back into the file.

 

Try making a small 2D string array and write it to a .csv (or .tsv or even .txt) file to check it out...

 

EDIT: Whoa, I just noticed you said you're using version 8!  I think the Write Delimited File was called something else back then but all the functionality you need is still available.

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 7
(4,574 Views)

Hi NIquist,

Thanks for the quick reply. I meant a csv file not .xlsx. I am extremely sorry for not making that clear. When you said process the data in the array, what did you mean? Because if I am guessing correctly, when I read the file back, since it is a csv file, it will give me something like Country,Name, Age, Height, Canada,X,,,US,Y,,, So if I wanna put 19 as age and 70 as height, how do I do that? Also even if it is possible, wouldnt it take a lot more time. For a small file, it makes sense, but for I large file or even for medium file, wouldnt it take a lot more extra time? So is it the most efficient way?

 

I know there could be questions like why am I not using toolkits or ActiveX if I am talking about efficiency. I dont really have an answer to that. If there is any possible way to make it more efficient that would be great. But if not, I am ok with this too. 

 

Thanks,

Kaawn

0 Kudos
Message 3 of 7
(4,564 Views)

Yes, when you read it back you'll get a 2D string array. It's easy and fast enough (until well above a million rows or so) to simply use Index array to get the 2nd column, Search 1D array to find your name, and use the result as row-index in another Index array.

Now you have your array of user data, use Replace Array subset to update the row and write it all back to file.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 7
(4,551 Views)

Hi Yamaeda,

I think I understand what you mean, but since I am new to Labview, I cannot really connect all the dots. Would you please be able to send me a pic of what you mean?

 

Thanks,

Kaawn

0 Kudos
Message 5 of 7
(4,548 Views)
Solution
Accepted by kaawn

I might suggest using the example finder in LabVIEW if you haven't tried that already, it was very helpful to me when I first started developing.  You can get to it in a project or VI from the "Help" menu select "Find Examples..."  Attached is an image of what it should look like with a search of examples for "spreadsheet." Hope this helps!

0 Kudos
Message 6 of 7
(4,539 Views)

I always leverage the shipping examples and usually recommend them but I looked at the spreadsheet examples and there's really not much there to chew on.  The problem is that to actually DO anything with data from a spreadsheet you have to use the array, number, string, etc. functions all together and build your VI to perform the specific tasks your application requires.  The OP will need to look at a lot of the examples (esp. the Fundamentals section) to code what he's trying to do.

 

This is the core of pretty much all computer programming though.  Reading, analyzing and manipulating data is key to almost every task a programmer is assigned to do and understanding these fundamentals is critical to success.

 

I suggest you make a little 2D array on a front panel and populate it with simple strings like this:2D array FP.PNG

Then start playing around and get familiar with all the tools LabVIEW has until you get comfortable enough to tackle your main project.  Here's a snippet of the block diagram.  I know you have LV8 so you may have to just re-create it.Search 2D Snippet.png

Practice with as many of the array and string VIs as you can.  Post back if you get stuck on something.  We'll help you learn but we usually try to avoid just coding a full solution so bear that in mind. Smiley Wink

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 7 of 7
(4,465 Views)