LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save data to spreadsheet

Solved!
Go to solution

Hello All,

 

I need to write 2D array of data to spreadsheet.

Every time I press some button, new file should be created with date and time in file name.

 

Can someone advise how to create this?

 

Thank you.

Milan

 

0 Kudos
Message 1 of 11
(2,743 Views)

Hi Milan,

 

which of these steps is a problem to you?

What have you tried so far? Where are you stuck?

 

Use FormatIntoString to create a file name according to your needs. (FormatDateTimeString might work too.)

Then use BuildPath to create a valid path for your desired file.

Then use WriteDelimitedSpreadsheet to save your 2D array…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(2,730 Views)

Hello,

 

please check attachment.

 

First I have problem creating subfolder, where all files will be saved.

 

Best regards.

0 Kudos
Message 3 of 11
(2,724 Views)

Hi Milan,

 


please check attachment.

First I have problem creating subfolder, where all files will be saved.

I cannot check the VI as I only have LV2017 available right now. (You might attach a snippet or a downconverted version of your VI.)

To create a subfolder you can use this CreateFolder function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 11
(2,720 Views)

Hi Gerd,

 

I tried with create folder first...

1.PNG

and with build path

2.PNG

 

0 Kudos
Message 5 of 11
(2,709 Views)

Hi milan,

 

error 10: you should not try to create an already exisiting folder…

error 43: you cancelled an operation, so it is not the fault of BuildPath…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(2,698 Views)

Hi,

 

i manage to create folder, but write spreadsheet always ask to chose file to write... 

I need to create file, not to open existing one...

3.PNG

0 Kudos
Message 7 of 11
(2,691 Views)

Hi Milan,

 

what is the full path that you feed into WriteDelimitedFile?

Does it contain a valid path, with all folders already existing and a valid filename?

 

Edit:

Found the problem - by debugging…

Look inside WriteDelimitedFile: inside WriteSpreadsheetString a new file is opened without providing a filepath. This will trigger the FileOpen dialog…

(You should have found out that too - by debugging…)

 

Solution:

Create the file on your own using FileOpen. Then convert the string using ArrayToSpreadsheetString. Then write that string using WriteToTextFile. Don't forget to close the file afterwards…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 11
(2,678 Views)

Hi Gerd,

 

I tried that way, but problem is obviously when I append file name (date, time) to the path, then probe shows that this is not a path. Of course, because this file doesn't exist yet. Why cannot create file with specific file name?

5.PNG  Thanks

0 Kudos
Message 9 of 11
(2,665 Views)
Solution
Accepted by topic author milan87

Hi Milan,

 

there are several forbidden characters in filenames. The colon (:) is one of them!

 

(This is basic knowledge for using computers and not related to LabVIEW.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 11
(2,658 Views)