LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I write data to an excel spreadsheet?

Hi,

After reading through the forums and doing some reading in general, I'm now pretty familiar with ActiveX and how to use it in LabView in order to interact with Excel. I still have a bit of a problem.

Basically i need to log some pretty basic data into an excel spreadsheet. All I need is to have 4 column names Chanel 1, Chanel 2, Ratio, Date&Time and then have all of the information underneath.

For now I was simply making a cluster of those 3 numbers and converted them to an array which output I would simply feed to a Write to Excel Spreadsheet.vi's 1D array input. This works fine, however I cannot insert text into such a cluster and that is the problem. I have looked through the example that writes a table from LabView into Excel, however that's not what I need, because I don't seem to be able to create the table programatically. There seems to be no tutorial on how to cluster or combine text and numbers and then write that to an excel file or should I say just write tab separated values into a file.

Thanks in advance.

Roman
0 Kudos
Message 1 of 11
(4,485 Views)
You're having a problem because you're trying to create an array from a cluster with mixed data types. An array has to have the same datatypes so the solution is to convert all of your numerics to strings. If you open Write to Spreadsheet File, you'll find directions on the diagram on how to modify it so that you can input an array of strings. Just don't forget to save it as a new name and in a new location.
Message 2 of 11
(4,467 Views)
Thanks for you reply Dennis.

Actually that is the first thing I've done. However that created another problem which keeps me from using this method. The problem is that when you convert a number to string, you lose precision in floating point numbers, as LabView converts them to whole integers.
0 Kudos
Message 3 of 11
(4,464 Views)
Hi Romulus,
Which function are you using to convert your number to string?
If you use 'Number to Engineering String' or 'Format into String' you will not lose any precision.
0 Kudos
Message 4 of 11
(4,458 Views)
If money is no object, I'd recommend you buy the "Report Generation Toolkit for MS Office". Works great and it's easy to use.

Otman
0 Kudos
Message 5 of 11
(4,453 Views)
Oops, forgot 'number to fractional string'.
0 Kudos
Message 6 of 11
(4,451 Views)
Ahh that sounds right David, thanks. I'll try that first thing tomorrow. Also money is not an object, I just don't think I need to buy a toolkit on top of another two I've bought, just to have 4 columns filled with simple data and no fancy formatting of any kind.
0 Kudos
Message 7 of 11
(4,439 Views)
I agree but it's a handy tool. i'm not a NI salesperson but it seems to me for any advance development you want to do with LV where time is a major consideration, NI has develop a solution. I'm not going to waste my time re-inventing the wheel if my company will buy the product. my time is valuable and I rather focus on the engineering side of an application rather than dealing with columns and such. that's why I suggested the toolkit. if I were working for a cheap company tha nickle and dimes you to death, then that's a different story.
0 Kudos
Message 8 of 11
(4,436 Views)
LabVIEW does exactly the type of conversion you tell it to do. You need to read the online help for the functions you select. You obviously used Number to Decimal String. Use Number to Fractional String or Format Into String. I don't think that your mistake makes me deserve a one star answer.
Message 9 of 11
(4,414 Views)
Otman you're right,

I've actually found a free excel toolkit that can be downloaded from NI. It's very handy.

Now as i've mentioned, money is not a problem, but my boss is not very good with computers and it's very difficult to explain to him what these addons are. Plus I don't want to waste my time like you mentioned, ordering and waiting for yet another addon that will allow me to do something very elementary and which should be included as a core component in an advanced SDK such as LabView.

Well enough politics 🙂 I'm going to try the recommended conversion.

Thanks for all your help!
0 Kudos
Message 10 of 11
(4,410 Views)