LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with saving string arrays to excel file.

I am running a LabView excutable (.exe) that tests an equipment and puts the results in a string array which is then saved to an excel file.  

The Excel file is in the following format 

 

Model No   Serial Number     Linearity              Phase                                  Test Date                     Operator Name           Current Rating   Test Current      Output Voltage

####                   1234             0.12345        +001.1234 deg                1/15/2015 8:47:38 AM             NAME                           0.1234                 0.1234                 1234

 

The table continues to populate as more tests are held.  I have run the same code on two computers and this is the format of the excel file (both computers running windows 8).  When the exact same code is run on a computer that runs on windows XP the table format changes to this 

 

Model No   Serial Number                               Linearity              Phase                                  Test Date                     Operator Name           

####                   1234                                        0.12345        +001.1234 deg              

                   1/15/2015 8:47:38 AM                    NAME                  

 

The last three columns are not there and the table format is no longer the same.  The first row has the six columns but the test date and operator name data are not on the second row.  The last three columns were added to the table recently.  Before adding them, the excel file produced by the third computer was in the correct format, the one shown below.  

 

Model No   Serial Number                               Linearity              Phase                                  Test Date                     Operator Name           

####                   1234                                        0.12345        +001.1234 deg                 1/15/2015 8:47:38 AM              NAME              

 

 

For some reason the format gets meesed up with the addition of the last three columns (only on the third computer).  I unfortuantely do not have access to the third computer as I try to figure out what is causing the problem.  I am told that the third computer is running well and that no changes are made manually to the excel table.  The wrong table is the output of the VI only.  

 

I know I have not given a lot of details regarding the problem but I would appreciate any suggestions or tips you might have to fix this problem.  I am new to LabView and not sure how to tackle debugging this issue.  The only difference between the first two computers and the third that I can think of is the operating system.     

 

I appreciate any help.

Thanks in Advance

0 Kudos
Message 1 of 6
(3,121 Views)

Are you absolutely certain that the application is identical on all three machines?

 

Is this writing to an Excel (.xls) file, or to a text file (.csv or .txt) that is opened in Excel?

 

Are you appending to an existing file? If so, what happens if you delete/rename the existing file, and start writing to a new file?

 

Can you upload examples of the actual files, both good and bad?

 

Is there any possibility there's a hidden character, like a tab or new line, lurking in there somewhere? For example, I've seen cases where the field for Operator Name was not limited to a single line, so the operator hit "Enter" after entering their name, and that new line made it into the log file and made a mess. That doesn't appear to be the case here for the Operator Name field, but maybe it's occuring somewhere else.

 

Do you have the LabVIEW code that generates the log file? Can you share it?

0 Kudos
Message 2 of 6
(3,114 Views)

I am certain the applications are the same. 

 

It is writing to an xls file.  The third computer does not have MS excel.  The file is opened with Notepad.  The format of the file is incorrect when it is opened with notepad.  The format is also incorrect when the file is transfered to another computer and opened with excel.  The files generated by the first two computers are correct when opened with notepad and excel.  

 

I have tried deleting, renaming, and deleting the content in the file.  None of these fixed the issue.  

 

Examples are attached.

 

The VI is very large (as saving results is only a small portion of the code).  I am using write to spreasheet.  I have connected my array to the 2D entry of the write to spreadsheet.  I wire an array indicator to the array connected to the write to spreadsheet and the dsiplayed array is correct and so is the excel file.  The problem is when the code is run on that thrid machine.  

 

Thank you!

Download All
0 Kudos
Message 3 of 6
(3,099 Views)

@MoAgha wrote:

I am certain the applications are the same.


The two files have different header rows. Where is the code that writes that header? Why would the "same" code write a different header (which is a static string) on two different machines? We need to see the code.


MoAgha wrote:

It is writing to an xls file.  The third computer does not have MS excel.  The file is opened with Notepad.  The format of the file is incorrect when it is opened with notepad.  The format is also incorrect when the file is transfered to another computer and opened with excel.  The files generated by the first two computers are correct when opened with notepad and excel. 


No! You are writing a TEXT file, and naming it with a .XLS extension. That's not really an Excel file, it's a text file that Excel can open. You'll note that if you look at the tabs (the field delimiters), the file contains the correct number of fields, it's just that those fields are either blank or contain a new-line.


@MoAgha wrote:
The VI is very large (as saving results is only a small portion of the code).  I am using write to spreasheet.  I have connected my array to the 2D entry of the write to spreadsheet.  I wire an array indicator to the array connected to the write to spreadsheet and the dsiplayed array is correct and so is the excel file.  The problem is when the code is run on that thrid machine.  

What's the data type of the 2-D array that's wired to Write to Spreadsheet? Is it an array of strings? How are you generating those strings? Is it possible that some strings are empty, or contain a new-line character (that you wouldn't necessarily see)? We need to see code, or at the very least a screenshot (please note, I'm on LabVIEW 2012 so if you post code, please save back for that version or earlier).

0 Kudos
Message 4 of 6
(3,088 Views)

The two applications are the same, however, the headers generated on the two different machines are different.  The last three columns (Rated Current, Test Current, and Operator Name) do not appear on the third machine ( I am trying to figure out why). 

 

The 2D array is a string array.  I attached a screen shot of the code that generates the file.  The entire code is in a while loop that does not stop until a stop button is pressed.   If the text file is initially empty, new data is inserted.  If not, new data is added to the original.  That is the purpose of the case structure.  I am using NI VISA to communicate with a number of devices.  The local variables are values from those devices.  The devices are a phase meter, a voltage DMM, and a current source.  

 

Thank you for your help!

0 Kudos
Message 5 of 6
(3,072 Views)

I think I'd need to see the entire code; there's too much missing from that screenshot. What's going on in the other cases of the cases structure? Where does the "InitialExcel" local variable come from? What's in it?

 

There's no need to reshape the header array to 9 elements, since it already is 9 elements. However, the screenshot doesn't show how that header is used.

0 Kudos
Message 6 of 6
(3,060 Views)