LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save Report to Excel File not Saving

Solved!
Go to solution

Hello!

 

I am working on a program that spits out a number of data points to an Excel. In the portion of the program doing this operation, the idea was to prompt the user for a file path at start, if the file already exists, then just pass it on, but if not, create a report with certain column headers and formatting and then pass that reference on. In this section of the program it creates a report, writes a row of data, and then saves and dispenses the report. From there the rest of the program should export a row of data to the Excel with each press of a button "Export".

 

The customer stated that they would like the Excel to remain open while the program is running so they can see whatever data has been exported  real time, and essentially have the report save every time data is written to it.. I have tried playing around with the SaveReportToFile and Dispense Report VIs with no success. Depending on what constants I wire to the DisposeReport nodes, the data is either written and then saved when the report closes, or the data is written and the report remains open, but it never gets saved along the way. Using the SaveReportToFile VI in my program doesn't appear to actually be doing anything. Saving only has happened with the DispenseReport VI upon closure of the report.

 

LabVIEW is working fine with Office, ActiveX and all, so doesn't appear to be any issues there. No errors are generated with any of my attempts. I read in another post about the Excel Instance of the SaveReportToFile. I am not sure how to implement this, but in my program it is just the standard instance with no option to change it to something else.

 

Simplified program attached.

Note: The program prompts the user twice for the file selection in the beginning. Not the intent and not sure why, but I haven't tried to fix yet, been focusing on the above issue.

 

I am using LabVIEW 2022Q3. I also tried repairing the RGT and a number of other Add-Ons yesterday.

 

Thanks!

0 Kudos
Message 1 of 12
(2,882 Views)

This works for me.  The Excel file opens in the background, I can see the data being written, and it is saved with every write and also after the program exits (which isn't technically necessary since the data is already saved).  If it doesn't work for you, there may be some incompatibility issues with the LabVIEW and Office versions you are running. 

aputman_0-1706038412608.png

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 2 of 12
(2,854 Views)

Thanks for the quick response aputman.

 

When I go to copy the code you provided, I can see a worksheet open, data being written to it with each button press, but at no point is the worksheet being saved, whether it be while the program is running or after the program exits.

Similar behavior no matter where or how I generate the initial spreadsheet and pass the file path through to the Save Report VI.

 

 

 

0 Kudos
Message 3 of 12
(2,823 Views)

I am also getting a file open error on the Save Report VI. Program can continue and keep writing, but still no saves occurring.

0 Kudos
Message 4 of 12
(2,810 Views)

Here is my VI.  It's definitely saving the file every time I write.  I can stop execution with the abort button (without executing the Dispose Report) and the file is indeed saved.

 

Are you losing the reference to the report?  The implementation of that VI is chosen at runtime based on the report type, so if you lose the report reference, it may be defaulting back to the version that does nothing.  Make sure you are wiring your report wire thru any other events that may be executed. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 5 of 12
(2,804 Views)

Downloaded your VI to my machine.

Only change I made was to the file path so it would save on my computer. 

 

Using your program on my machine, upon start of the program an Excel sheet opens, labeled "Book1" which I will say is contrary to the name I specified in the file path in the program. Data is written to each row, and then program stops when I hit the stop button. I close the Excel and then go to the location and no new worksheet has been saved, under "Book1" or the name I specify in the file path.

 

No errors or otherwise.

0 Kudos
Message 6 of 12
(2,797 Views)

The Excel sheet that opens is called book1 because no template was specified in the "Create Report" VI.  The filename you specified isn't used until the save button is clicked.  This is expected behavior. 

 

I'm not sure what to tell you.  Like I said before, it may be a compatibility issue between RGT and your version of Office.  You can try putting some probes on the wires in the "Save Report" VI and see if the correct implementation is being called and that the path is correct. 

 

 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 7 of 12
(2,732 Views)

You might also try restarting your computer or at least checking Task Manager to make sure Excel is not running.  I've seen it happen before, especially during development, where references weren't closed and multiple Excel applications were running in the background, causing havoc with my code.  This may not be as much of an issue now but something to consider. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 8 of 12
(2,729 Views)

Understood, the comment you made about the template makes sense.

I changed around what file paths are passed to the VIs and the report is getting pulled from the right place.

Still no success with the Save function...did a restart on my computer and checked that Excel was not running in the background either.

0 Kudos
Message 9 of 12
(2,715 Views)

Tried this on another machine from a colleague, same issue with the not saving.

0 Kudos
Message 10 of 12
(2,710 Views)