06-28-2013 02:06 PM
Hello LabVIEW wizards...
So I'm using the Write to Spreadsheet File VI to create a nice, formatted, tab delimited report file from one of my data acquisition programs. In one of the cells of the resultant spreadsheet file I want to put a binary string of all my control values so when you open the data file all the control settings used to produce it are restored but the string is nicely hidden when the report is viewed in Excel.
The problem is that the flattened binary string uses tabs and returns as part of its syntax so the Write to Spreadsheet File VI has it going all over the place. Worse still, I can't unflatten the string when I open the text file due to "corrupt or unexpected data."
If I concatenate the flattened string with quotes around it it looks great and is placed in a single cell in Excel, but when I open the file in LabVIEW it still occupies multiple array elements. I isolated the binary string using the Read Text File VI and got a subset of the string between the quotes but it still won't unflatten it correctly.
Essentially, I need to know how to get LabVIEW to pull a literal string full of special characters out of a spreadsheet file and unflatten it. Any help you gurus can provide is very much appreciated.
Thanks,
Jordan
Solved! Go to Solution.
06-28-2013 03:14 PM
Jordan,
I suggest that you change the formatting of your embedded string by replacing the tabs and returns with some other characters which will not be interpreted as commands by the spreadsheet functions. Without knowing how you are representing your control values in binary, I cannot suggest particular characters.
If two non-printing characters exist which do not appear in the control data, then it is easy: Just find and replace the tabs and returns with those characters. If no such characters exist, then something more complex would need to be done such as escaping the special characters. Either way create two subVIs - one to remove the tabs and returns before writing the string to the file and one to restore them after reading.
Lynn
07-02-2013 08:26 AM
Thanks, Lynn! I just wrote a quick sub that searches and replaces tabs, carriage returns, and line feeds with some easily recognized tokens. Works great!
07-02-2013 11:29 AM
Jordan,
Glad you got it working.
Sometimes a different perspective is all it takes.
Lynn