04-23-2015 11:05 PM
woops, i refered to the wrong person, i meant bob. my bad
04-24-2015 11:52 AM
Am I correct that you do not have access to the RGT? If so, that would be too bad, because it is so easy and intuitive to do what you asked about with the Toolkit. Oh, well, there are always "other ways to do things" ...
BS
04-24-2015 12:08 PM
Oops, I missed your previous message. Here is a simple VI that opens whatever Excel file you specify, waits for you to modify its contents, then when you push the Stop button (the only Control here), it saves the file with the same name. If you now open the file (in Excel, say), you'll see the modified content. Of course, if you used LabVIEW to also add content (not shown here), you'll see that, too.
Two "tricks" I used here -- the RGT doesn't have a "Prompt for file name", so I made one by wiring an Open File and Close File together, using the behavior of Open File to "ask the user if no file is wired", and the behavior of Close File to return the File Name. I similarly used a "naked" Event Structure as a "Wait until someone pushes the Stop button".
As you can see, this is pretty simple to do ...
Bob Schor
04-24-2015 01:12 PM
04-24-2015 05:51 PM
04-26-2015 12:13 PM
so ben, from your vi, i understand that each time theres an edit, it overwrites directly from the very first cell. how would you modify it so that it updates at very cell im updating? im not that familiar with activeX.
04-26-2015 12:43 PM
I'm just curious -- what do you need to do that my very simple method won't do? Or do you not have access to the Report Generation Toolkit?
Note that if you follow my general method of using the RGT to open Excel, then (with Excel open) use Excel to edit the values in the WorkSheet, it should be obvious that any data that you previously read from the WorkSheet will not be modified in the LabVIEW copy. However, you can always get the new value by re-reading the modified cell.
[I'm now thinking if I can "invent" a reason for not using the RGT ...]
One possible question is "How can I detect if the User has modified the WorkSheet, i.e. how do I know when the LabVIEW data I have in memory is "wrong", i.e. not the current value in the WorkSheet"? A related question is "How do I prevent the user from modifying the WorkSheet"?
I think I can answer the second question (though, to be honest, I haven't tried this). It is possible to open the Excel WorkSheet "minimized", which I assume means that it is not visible. [Another question -- can the user easily make it visible without outside LabVIEW?]. You can't (easily) modify what you can't see.
If there are other reasons, I'd be interested in knowing them ...
Bob Schor
04-26-2015 01:25 PM
b9 a écrit :
so ben, from your vi, i understand that each time theres an edit, it overwrites directly from the very first cell. how would you modify it so that it updates at very cell im updating? im not that familiar with activeX.
You haven't provided us any information on what you want to do with the data. How to you want the data presented (array, table, ...)?
From the original post you asked: "Is there any possible way to read new data from excel file into labview as I enter new data into the excel sheet". The vi I posted does this, it gives to new values you entered in LabVIEW. The data is not updated in a cell, it is a 2D array because in Excel you can update a range of data at once. If you write a single cell it will return a 1X1 2D array, If you write a block of 2 rows and 3 columns it will return a 2X3 2D array.
If you need all data values you can use the value change event to read all cells.
Ben64
04-26-2015 07:38 PM - edited 04-26-2015 07:41 PM
ben ,my bad, forgot to mention what i was doing, becuz i planning to constantly read in data to plot graph in real time. so my measurement unit will constantly take data automatically and add in new data by columns.
bob, if it is supposed to be exactly like your pic, i tried but i cant get it to work. did i left out something?
04-26-2015 10:22 PM
My snippet was supposed to illustrate the principle that you could open an existing Excel file in LabVIEW, modify it in Excel, tell LabVIEW to stop, and LabVIEW will save the modified file. This was in answer to the question that we thought you were asking originally (that RavensFan said No and that I said Yes). As noone (like yourself) ever set us straight, and you were never very clear what you were trying to do, I'm afraid I totally "missed the boat".
So why don't you try to clearly state what you want to do? If you are asking "Can I use LabVIEW to write data incrementally into Excel, namely a row here, a column there, a cell over here", then the answer is, again, Yes. However, in order to design code to do this, you need to specify exactly what you are trying to do, and what the appearance of the final Worksheet (or Worksheets) will be.
By far the easiest way to do any "Excel with LabVIEW" processing (IMHO) is to use the Report Generation Toolkit. So what is it that you are trying to do?
Bob Schor