From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

time stamp to excel sheet

I want to print time stamp every second to an excel sheet, tried 1000 of times to add row to the sheet but failed, any clue how to?

0 Kudos
Message 1 of 7
(2,742 Views)

Here's a VI I wrote to open an excel sheet, and write the current timestamp to the active cell, after setting its cell format. You could edit this to write multiple values.

 

Regards,

Prashanth N
National Instruments
0 Kudos
Message 2 of 7
(2,738 Views)

You will need to use a loop, and increment the cell number each time you write.

Hope this helps.

Prashanth N
National Instruments
0 Kudos
Message 3 of 7
(2,737 Views)

thats the problem, i cant do it automatically

 

0 Kudos
Message 4 of 7
(2,730 Views)

Why not? Can't you use the loop index to increment the cell position for each iteration?

Prashanth N
National Instruments
0 Kudos
Message 5 of 7
(2,723 Views)

That's because you're wiring the N value of the for-loop to the "column" element of the cell cluster, and you are wiring a constant of 1 to the "row" element of the cluster. You also have several issues with the code:

  • Do NOT hard-code a path the way you are doing. What will happen if someone else tries to run this code? What will happen if it runs on another computer that has Windows XP? Use a control and set it to a default value if you want.
  • No error handling whatsoever.
  • Do not use integer constants in lieu of enumerations. The VIs you are calling have parameters for which enumerations are provided. Use them. Right-click on the inputs and select Create->Constant. This will create the enumerations for you. They are self-documenting.
  • Do not have a time delay that cannot be bypassed if there is an error. You are running the loop 500 times. What will happen if there's an error on iteration 20? The loop still has to run 480 times, forcing you to wait 480 seconds before you can stop.
  • Be aware that timestamps between LabVIEW and Excel are different, since they use different epochs. This has been discussed ad nauseam in these forums, so do a search and you will find out how to deal with this.

See attached modification as a starting point. You should also review the LabVIEW training materials. To learn more about LabVIEW it is recommended that you go through the introduction material, tutorial(s), and other material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. There are also several Technical Resources. You can also take the online courses for free.

 

 

Message 6 of 7
(2,722 Views)

smercurio_fc wrote:
  • Be aware that timestamps between LabVIEW and Excel are different, since they use different epochs. This has been discussed ad nauseam in these forums, so do a search and you will find out how to deal with this.



Or just wait a few seconds an Jeff will post a link to This idea (just like almost every time I see Time and Excel in a subject line)


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 7
(2,714 Views)