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: 

read tables from word file

Hi,

Can anyone explain how to read several tables(that has strings and numerics) from a word file to labview? I am using LV report generation toolkit for MS office and writing the user entered arrays in LV to a word file. I want to read that data back into labview. I tried using Read from spreadsheet file.vi and modified it to read strings as well. But what i get is some unidentified characters on my LV front panel. I have attached a sample word document that i would like to read in labview. Can someone please suggest a method to read all the tables in the attached word file to LV. I am using LV 6i version 6.0. and I also have the LV report generation toolkit for MS office.

Thanks in advance
0 Kudos
Message 1 of 16
(5,490 Views)
The problem is that the report generation toolkit creates a MS Word document containing the data. The Read from Spreadsheet.vi routine attempts to interpret the data as a tab-delimited text file.

If you want to have the data be readable from LV and have a pretty printout from Windows, you'll need to create two copies of the output data: One with the report generator and one that saves the same data as a tab-delimited text file.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 16
(5,490 Views)
I agree with your answer. However, I do not want to save the data in two different formats. I have tried another solution. I have used the excel specific vi's from the report generation toolkit to write the attached file data to an MS excel file. When I try to read the same data back to LV using read from spreadsheet file.vi, I get data back that looks like "?Ia!?a". I have changed the allrows, single row and array type in the read from spreadsheet.vi to string arrays and also I am using %s as the format.
Any suggestion or idea why this is happening? I am attaching the VI that I have developed. It will work for those who have the report generation toolkit installed.
Thanks in advance
Download All
0 Kudos
Message 3 of 16
(5,490 Views)
As mentioned in the previous answer, Read From Spreadsheet File.vi reads a text file with comma or tab separated data - it is not a read from Excel and that is why you are reading garbage. To read from Excel, you'll need to use ActiveX. I don't have the report generation toolkit so I don't know if there is a read Excel function included but if there's not, I believe there was an example once posted to this forum or in the example program database.
0 Kudos
Message 4 of 16
(5,490 Views)
As Dennis pointed out, you have the same problem as originally, but with a different program. The VI called "Write to a Spreadsheet File.vi" should really be named "Write to a kind of file that a spreadsheet program can open.vi".

The examples that ship with LV show how to interact with Excel. However, you'll be reading one cell at a time, which means that if you have a large amount of data you may still be hosed due to the amount of time required to pull it all back in.

Mike...

ps: the examples are also online at:

http://zone.ni.com/devzone/explprog.nsf/6c163603265406328625682a006ed37d/83bcdadcf22cd5b586256616007d6069?OpenDocument

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 5 of 16
(5,490 Views)
Thank you guys for all the help and effort. The reason I bought the report generation toolkit was to avoid using Active X. I did look at the example and I will try to work using that example as my reference point. However, I would appreciate if you guys can think of something that will avoid the use of Active X.

thanks again
0 Kudos
Message 6 of 16
(5,490 Views)
Looking at your concerns, the copy that would be the easiest to drop would be the Word document. Do you really need that as a file, or would a hardcopy printout of it be enough?

If all you really need is a printout there's no need to save anything to a file, and if the report you posted is typical of what you are doing, the report generation toolkit is massive overkill. All you really need is a properly-formatted VI front panel that you print. I can explaing how to do that and send you code if it will help...

With this approach only one file is generated--the tab-delimited text file.

Alternately, check with your users about how they plan to use the data from the system and you might be able to drop the tab-delimited d
ata file by inserting the data directly into a database (which is where it probibly belongs anyway). I can also provide some guidance in that arena if desired.

Finally another thing I have done quite successfully in the past is create a "viewer" application that allows users to examine the data and if desired print it out. A viewer application could fetch data from files on the user's hard disk or extract it from a database.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 16
(5,490 Views)
Hello Mike,

Thanks a lot for all this information. I have been playing around with active x so far and yet no success. I am giving an overview of what I have done so far. I have created a VI that will allow users to input information into arrays of strings. Each 2D array will be called based on the ring control in the front panel. The information that the user enters is typically strings of characters (say, the list of things to do for the day). After the user has entered all the desired fields, I am saving that information to a word (or excel) file so that the user can just print it out. I am using report generation toolkit to do that since it does not need active x for formatting the data in word or excel. So
basically, the word (or excel) file will consist of several tables with information entered by the user in each table using LV.
Now, if the user wants to modify that information on a later day, I would like to call back that information from the word (or excel) file so that the user sees the information in the word or excel file. He or she can then add or delete and make changes and replace the existing word file or excel file and then print out. Now, the reason i am saving the information in word or excel is bcos it is well formatted and the hardcopy looks neat when printed out. I do not have to compulsorily use word or excel to create the database. I hope i have explained my situation better.

To do this simple function of reading tables from an excel or word file, i do not want to use active x. ANy help would be greatly appreciated.

Thanks in advance.
0 Kudos
Message 8 of 16
(5,490 Views)
You can leave your data in text format if you want to keep it simple. Excel or word can read text formatted file. From excel or word, you can make change to the data and save as text file.

guindon_jp@hotmail.com
0 Kudos
Message 10 of 16
(5,490 Views)
Mike,

I also like your "Viewer" application. Could you explain more about what it does and how it functions?Basically, I want the user to input data to LV manually and then programmatically save the data in any format that loooks good while printed out.
And then if a need arises to modify that data, LV should pull out the old file and allow users to make any change and replace the file. The part i am stuck is in reading a file from the database i have created. U can see the word document that i have attached to see how i would like the data to saved.

Thanks again
0 Kudos
Message 9 of 16
(5,490 Views)