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: 

Write to spreadsheet adds carriage return

Solved!
Go to solution

I am using build array function to put together a number of strings and build an array of strings.  The build array is in a while loop.  A new line is added to the array every loop.  I am using write to spread sheet function to save the spreadsheet to a file with xls extension.  For some reason, a carriage return is inserted within the array.  The array has 9 columns and a carriage return is put after the fourth column.  I have not added this carriage return.  Does anyone know why write to spreadsheet might automatically add a carriage return and how to remove it?  

 

Thank you!

0 Kudos
Message 1 of 13
(5,029 Views)

I'd have to see some of your code.  My guess is that you are putting in a End Of Line in the string for the 4th column.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 13
(5,025 Views)

My VI looks something like this.  I do not have the carriage return problem on my personal computer.  When I transfer the code to a stand alone (.exe) and run it on a different computer the carriage return problem appears.  The saved file has has a carriage return before the time column.   

0 Kudos
Message 3 of 13
(5,006 Views)

Hi,

 

I took your posted VI and compiled it to an exe.  I do not see the carriage return problem you are describing?

If you compile the VI you attached, do you see the problem or is it only in the original main application (that you cannot share)?

If the compiled exe works on your PC, does it also work on the 'different' computer where you see the issue with your original code?  

 

-If it does work, then the issue must be in the source code for your original code.  Sometimes, if you re-size string constants, for example, it can be hard to see carriage return's.

 

Another thing it could be perhaps, is if you are calling the "write spreadsheet" in two different places in your main code, then the way it works is it will write your two (different) input arrays to separate lines.  If it is as in your example VI though, there should be no carriage return in the "middle" of the array.

 

For debug purposes, you could consider making a VI that takes a 1D string array input, iterates over each element in the array and searches for the carriage return character and gives an error/message on what iteration it found it, then you can back-track from there to see in the code responsible for making the string that went into that index.

QFang
-------------
CLD LabVIEW 7.1 to 2016
0 Kudos
Message 4 of 13
(4,993 Views)

The Carriage return appears after the first row.  There is no carraige return after the fields row.  It appears before the time stamp starting row 2.  

0 Kudos
Message 5 of 13
(4,992 Views)

Here is the original code.  It is kind of big.   I am using the write to spreadsheet more than once.  Could you please explain how that might cause problems?  

 

Thank you

0 Kudos
Message 6 of 13
(4,986 Views)

You will need this file to run the code.  It should be saved in C:\auto_labels\

0 Kudos
Message 7 of 13
(4,982 Views)

This xls file

0 Kudos
Message 8 of 13
(4,981 Views)

This xls file

Download All
0 Kudos
Message 9 of 13
(4,978 Views)
Solution
Accepted by topic author MoAgha

I do see some reading from an instrument.  If the instrument is appending the End Of Line as a termination character, that is likely where your extra carriage return is coming from.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 13
(4,970 Views)