02-08-2023 02:46 AM
The issue I am facing with this is that there is no new file created in the specified folder. Even the existing file does not have data added to it (though I have managed to do that separately, but that's not my desired outcome right now).
I want to use an existing .xlsx template, write data into its Sheet2 (to link to Sheet1) and save it as a new .xlsx file with a different filename (using datetime to differentiate). I'm using LabVIEW 2022 (32-bit). Apologies for any obvious mistakes, I'm fairly new to this software.
02-09-2023 07:33 AM
To build a Path for a file, you should use the Build Path function. I really dislike using a TimeStamp as a file name: it gives you no clue what data the file contains, it is hard to sort, confusing to the eye to read, etc.
To keep my files-of-the-same-type-of-information straight, I use the "Incrementing Suffix" function, which has (for my use) one tiny flaw -- if there are no files with the same name, it creates a file without a suffix. I fix this by "wrapping" my own code around this function -- I create the file, and see if the "created name" is the same as the "starting name". If so, I create it again (causing a name with the (001) sufffix to be generated) and delete the suffix-less name. I don't remember, but you should probably close the un-suffixed file before deleting it.
Here's a Snippet:
Bob Schor
02-10-2023 01:57 AM
@ashfeq :
Are you sure LV has the correct write privileges in the target folder? No error reported?
I replicated your code on my PC and the new file gets created correctly...
(yes, there are 'more elegant' ways of building a filepath 😉 )
02-11-2023 07:21 PM
Things to check:
1. It automatic error handling turned on? If not, then you will not see the error if the template file cannot be opened
2. Does the template document have a sheet 2? If not, no data will be written
3. Single-step the code and see if your template has been opened, Sheet selected and data wriitten
4. Replace the hard-coded template name with a file path control and browse for the file. This insures the path is correct.
5. Double-click the NI Excel VIs before running the program to see if the control values make sense
You named the image LVsnippet, but did not use the Edit -> Create VI Snippet to create it....
02-12-2023 09:14 PM
Thanks to all who replied,
I have managed to make some progress. Firstly, with the new changes I've made in reference to all your suggestions, I was able to create new .xlsx files with incrementing suffixes and removed the datetime naming as Bob suggested.
However, now, I am unable to open the excel file as it gives the error as attached in the image below. I don't think it is a problem with the permission for writing to the directory as I am able to create the files now, right?
Also, for Michael, I tried disabling the program from the 'Save file to report' till 'Dispose report' VIs. What it did was to write the array into Sheet2 of the original template excel 'LabViewTest'. Thanks for the help in creating a snippet! I've attached a proper one this time.
02-13-2023 02:34 AM