LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

convert strings to excel with order

Hi AIEXINUK,

 

the dynamic outputs are simply like: 234134,2334535,131321,3453536......(value and comma and value and comma and value......),

So you receive a string of comma separated values? Why don't you convert this into an array of strings using the SpreadsheetStringToArray function?

(What are "dynamic outputs"?)

 

I don't have the skills to change how it was programmed (i am still a newbie) so I assume that I can change or add something after the output.

Don't change the device driver VIs - change the routine that calls all those device driver functions!

Here you can process the received data as much as you want…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 20
(1,369 Views)

So something like this then?

 

image.png

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Message 12 of 20
(1,364 Views)

Yes! just like this.

 

I don't have the VI now so I just tried to use the circuit but the output from the excel is not expected..(got all the values into one column)

Here is attached files.

0 Kudos
Message 13 of 20
(1,355 Views)

I am assuming that the "unexpected" part is that it was in column.

To put the data in rows, simply wire a TRUE to the transpose input

 

image.png

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
Message 14 of 20
(1,341 Views)

You can transpose your 2D array before goes into the Write to Spreadsheet.vi with...  You guessed it Transpose 2D Array.vi.  if you want new rows in your spreadsheet data, then you need to a carriage return (newline) in your string data.  Commas (or TABs depending on the delimiter you use) separate the string data into a new column.  Newlines separate the rows.  The escape character you can put in a string to make a newline is "\r\n".

 

EDIT:  Ah yes, I forgot about the transpose input.  Open that VI to see how it uses the Transpose 2D Array node inside.

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 15 of 20
(1,338 Views)

That is what I want to accomplish, thanks!Cat Happy

 

Here is the new thing, when  I try to type the value like: 1.1515,1.5656 into string, it works fine and shows the correct value in the excel. But when I try to type the value like1.73984200E+07,+1.10680000E-04, somehow these values can not be correctly displayed in the excel. However I got the indicator after the 'spreadsheet to array' function while it shows the same values. Which means something goes wrong when the data flows into the 'Write the spreadsheet file' function?

 something wrong.PNGwrong excel.PNG

 

0 Kudos
Message 16 of 20
(1,332 Views)

Hi AIEXINUK,

 

But when I try to type the value like1.73984200E+07,+1.10680000E-04, somehow these values can not be correctly displayed in the excel.

Please read the help for the WriteSpreadsheetFile function!

Read the help for ALL its inputs - also those you left unwired!

(Excel only shows what YOU have saved into that file: examine the file using an ordinary text editor!)

 

Btw: why don't you save that string constant directly to a file using WriteTextFile (using a filename suffix of CSV)? Excel will load it easily as you already got a spreadsheet string: no need to convert from string to numeric array and back to a string to save to a file!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 17 of 20
(1,329 Views)

Hi GerdW,

 

Very helpful! Solved the problem like that I never had!

 

One more questions about adding header into my excel from labVIEW, I saw many solutions in the community, one is: https://forums.ni.com/t5/Example-Programs/Add-a-Simple-Header-to-a-Spreadsheet/ta-p/3521839?profile....

didn't work.PNG

 

I try to follow but it didn't work. While I am wondering if you could provide some ideas.

 

 

 

0 Kudos
Message 18 of 20
(1,321 Views)

Hi AIEXINUK,

 

I try to follow but it didn't work. While I am wondering if you could provide some ideas.

Did I suggested to read the help on WriteSpreadsheetFile? Especially for those inputs you left unwired?

Re-read it again!

 

Hint: you want to append data to a file already containing the header line(s)…

 

On your image: Why do you want to write the exactly same data into the file again and again? (Infact forever!)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 19 of 20
(1,312 Views)

Hi GerdW,

Cool, solved the problem now. Didn't understand what does append file mean, after tried many times by myself and now everything is clear.

Thanks for your help, have a good day.

0 Kudos
Message 20 of 20
(1,306 Views)