Jump to content

Export data from LabVIEW to Excel (.CSV) in real time


Recommended Posts

Hello ,

I am trying to Export data from LabVIEW to an Excel file(.csv) in real time. I Need to see the data in a real time , which are written in the Excel without Closing the Excel. my Problem is i can see the real time data writting in LabVIEW . But in Excel i can see the data only after stoping my LV program. Is there any way to watch real time data writting in each column the Excel. I have attached my LV program.

Write_CSV_date_time.vi

Link to comment

There is a "Flush File" function in the "File I/O >> Adv File Funcs" menu that you can have execute after every write.  

However, If you already have Excel open to view the CSV file, I don't believe that Excel will automatically update your spreadsheet contents every time the file changes if that is what you're trying to do. I haven't tried that myself. 

If the above doesn't work, it may be that Excel doesn't constantly monitor the file and automatically update.  You could try using the "Refresh All" button in Excel under the "Data" menu, but you'd have to do this manually.  Additionally, you'd have to open your reference to the file with permissions configured in such a way that it doesn't block other applications from using the file if another already has it open.

Someone more experienced in Excel and actively monitoring file contents may be able to provide more info.

Link to comment

Hello Bryan,

However, If you already have Excel open to view the CSV file, I don't believe that Excel will automatically update your spreadsheet contents every time the file changes if that is what you're trying to do. I haven't tried that myself.

--->>>>> yes i am trying to keep ma excel sheet open while data  are updating in real time, which i receive per second from LabVIEW.

Link to comment

Excel actually locks the file so only it can edit it.  So if you close the file in LabVIEW, you will not be able to reopen it to add more data.  Yes, I have personal experience with this.

 

Since you are using a CSV, I would recommend something like UltraEdit.  UE edits backup files and it will let you reload files that have changed while you have it open.  I'm not sure if Notepad++ does the same.

Link to comment

I'm not sure that you're going to be able to (easily) do what you want to do without some advanced programming to automate/manipulate Microsoft Excel (for instance, using ActiveX or dotNET), even then - I'm not sure it's possible to do what you're trying to do as it involves Microshaft software, over which LabVIEW will have limited ability to control.

I agree with 'crossrulz'.  Whomever is pushing this requirement may need to reevaluate the need for this functionality.

Link to comment

I agree that you should probably push back a bit on the requirements.

If you want to get real weird with it, I've worked with a group that did all of their hardware interaction in LabVIEW, built that code into a DLL and then called it from an excel macro that was continuously running.

Link to comment
On 7/2/2020 at 6:38 PM, jacobson said:

I agree that you should probably push back a bit on the requirements.

If you want to get real weird with it, I've worked with a group that did all of their hardware interaction in LabVIEW, built that code into a DLL and then called it from an excel macro that was continuously running.

Hello Jacobson, Can you please help me to get this DLL  and use it LabVIEw, may be you have that code.

Link to comment
On 7/2/2020 at 6:01 PM, Gribo said:

You should use the Excel .NET API. You will see your data as it is added to the spreadsheet. 

Also, you can do this with OpenOffice/LibreOffice if you don't want to pay for Excel.

Hello Gribo, do you somthing like code or exmple, where i can see my data in real time. It will be very helpful for me.

 

Link to comment

Here you go. 

This is not a production code. You will have to close references when you are done with a specific object.

2 things to note:

1. Excel, like VB is 1 based. 1st index is 1.

2. Don't leave an empty property node input. Wire a 'missing' type to any gray (optional) input that you don't use.

Excel sample.png

  • Like 1
Link to comment
22 hours ago, Gribo said:

Here you go. 

This is not a production code. You will have to close references when you are done with a specific object.

2 things to note:

1. Excel, like VB is 1 based. 1st index is 1.

2. Don't leave an empty property node input. Wire a 'missing' type to any gray (optional) input that you don't use.

Excel sample.png

Thank you Gribo. I have attached my VI. But i got 2 Problem: 1. I was not able to insert property node "Type" > "missing". 2. I get error from my Invoke node "Add". Do you ha ve any idea??

Excel_Sheet.PNG

csv_update.vi

Link to comment
4 hours ago, Gribo said:

Type object is in the System namespace. Click .NET connectivity -> Invoke node -> Select class -> System -> Type -> Missing

Great man it is working… Now i just Need to find out how can i write random number continously in each row and column in each 500 ms.

Link to comment
On 7/2/2020 at 4:56 PM, crossrulz said:

CSV is a text file.  So why are you stuck with Excel?  It will not do what you want.  What's wrong with making another viewer?  Push back on this requirement to figure out what the real goal is.

Hello crossrulz,

The actual target is to see each data in .csv Format but i am not able to find real time update in .csv , when LabVIEW send a data in each Minute, it should be also updated in csv while it is opened. I Need to monitor each data send from LabVIEW while csv is receiving it. I am not able Keep open csv file and monitor while it is receiving data from LV.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.