Jump to content

Text file to excel through Labview


Recommended Posts

I have a created an output text file of my data using Labview. I need to be able to export this file into a specific sheet of my excel template. I need to write the text file first because it is not simply an array, but a combination of several strings and arrays. This is how the program was originally written, and i do not know how to change this. I am looking for an easy way to export the existing output file (.txt) into my excel workbook after the initial creation of the text file.

Link to comment
I have a created an output text file of my data using Labview. I need to be able to export this file into a specific sheet of my excel template. I need to write the text file first because it is not simply an array, but a combination of several strings and arrays. This is how the program was originally written, and i do not know how to change this. I am looking for an easy way to export the existing output file (.txt) into my excel workbook after the initial creation of the text file.

If your text file is a tab delimited file with new rows seperated by carriage return and linefeed, then you can simply open it from Excel. Excel should recognize the format and load it up without problems.

The other option is to do activex com to Excel and pump the data directly into Excel. This option may take several days or weeks to get working (if you've never done this type of thing before). This method is cool, you will grow as a programmer and you can impress others with the new knowledge you have attained. Of course your boss might yell at you for pushing out the deadline on delivery... :P

Link to comment

Thanks for the help. I will try using ActiveX for the first time. In the mean time, our current process requries chyanging the name of the output text file, then running an excel macro to import the data. I know how to run the excel macro via LabView, but is there a function to change a file name? It is a .txt file.

Link to comment
Thanks for the help. I will try using ActiveX for the first time. In the mean time, our current process requries chyanging the name of the output text file, then running an excel macro to import the data. I know how to run the excel macro via LabView, but is there a function to change a file name? It is a .txt file.

Here's a fast way to start using the ActiveX method:

Excel Toolkit (GOOP)

post-2800-1130174299.png?width=400

It works really slick!

Also...

LAVA Forums > LabVIEW > The LabVIEW FAQ > Miscellaneous > How do I rename a file?

Link to comment
Thanks for the help. I will try using ActiveX for the first time. In the mean time, our current process requries chyanging the name of the output text file, then running an excel macro to import the data. I know how to run the excel macro via LabView, but is there a function to change a file name? It is a .txt file.

There is no need to rename the file. Just open it in Excel. Have you tried this?

WMassey

Thanks for the link...

Link to comment
There is no need to rename the file. Just open it in Excel. Have you tried this?

Thanks for the link...

A very "quick and dirty" trick :shifty: I've played on Windows based machines is to give a tab delimited text file an .xls extension. This causes Windows to automatically open the text file through excel when the user double clicks on the file. It DOES mean that if the user makes some modifications to the file through excel, they must be wary as to whether they save the file back as a text file or as an excel file. Excel does inform them of this when they attempt to close or save the file, but sometimes the user might not bother to read all of the information in a dialog.

Of course, inserting data directly into Excel through activeX has its advantages (e.g. formatting, formulas, and other fancy stuff!), but its just not as "quick" or as "dirty." :P

-Pete Liiva

Link to comment
A very "quick and dirty" trick :shifty: I've played on Windows based machines is to give a tab delimited text file an .xls extension. This causes Windows to automatically open the text file through excel when the user double clicks on the file.

Also, you can also have Windows open the file in Excel by calling it from the command-line using System Exec. Just pass the path to the file, as the command string and let Windows do the rest. This method will also work if your have OpenOffice registered as the handler for XLS files.

Link to comment

Thanks for the help guys. I know about opening text files via excel. My goal is to "dummy proof" this process and have LabView automate as much of the data transfer to excel as possible instead of relying on our rather inept operators.

So far the LabView program creates an output text file. I need to then transfer that text file into a specific sheet of an existing excel workbook either directly or by renaming the text file and running an existing macro through excel.

I'll try playing with the ActiveX and GOOP functions. I have never used ActiveX, though, so any tips will be greatly appreciated.

Link to comment
I'll try playing with the ActiveX and GOOP functions. I have never used ActiveX, though, so any tips will be greatly appreciated.

You don't really need too much, if any, ActiveX experience to use the Excel Toolkit that I referred to earlier. That's been done for you. I've attached an example that uses a VI I pulled out of a working system. I've added a dummy front end to generate some fake data for it to operate on. You can see some of the stuff you can do with the toolkit in regards to generating Excel spreadsheets. This example is in LV 7.1.1 and I believe it includes copies of all the VIs needed to run it.

Download File:post-2800-1130413684.zip

Link to comment
  • 6 months later...

A tip for those that try this toolkit with LV 7.1/8.0:

I had to change one of the property nodes in four VIs to make this library mass compile. Inside excel.llb, you'll find the "Excel write string/numeric" and "Excel read string/numeric" VIs have a broken property node pointing to a "Range->Value" property. Change this to "Value2" and the VIs should work.

This IS a slick toolkit though! :thumbup:

Joe (orko)

Link to comment
A tip for those that try this toolkit with LV 7.1/8.0:

I had to change one of the property nodes in four VIs to make this library mass compile. Inside excel.llb, you'll find the "Excel write string/numeric" and "Excel read string/numeric" VIs have a broken property node pointing to a "Range->Value" property. Change this to "Value2" and the VIs should work.

Joe (orko)

I think the problem is an Excel version issue rather than a LabVIEW version issue. I had the exact same problem using the LV Report Generation Toolkit when I switched to Excel 2003 from Excel 2000 (or maybe it was Excel 2000 from the previous one).

George

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.