LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Report generation

Solved!
Go to solution

Hi everybody. I'm pretty new in using LabVIEW, but I'm having lot of fun until now.
Just one simple question.. I'm acquiring data from an instrument and then when the user push the classic "Save&Exit" button it generates an excel file. Straightforward.
My code is running well, but the only things that I don't understand is that it opens microsoft excel in the background together with the dialog asking for name and folder to save it.
I was wondering if it is possible not to let Excel open and stay in background.
Attached the relevant part of the code.
Thank you for your support. 

0 Kudos
Message 1 of 16
(3,945 Views)

I am relying off of memory here but if you change your Ring Enum from "normal" to "no change", you should get the behavior desired.

 

One other thing to note, always upload your VI and not pictures. It gives us things to look that can affect what you're seeing or we could suggest alternatives that may be faster/easier to implement.

Message 2 of 16
(3,935 Views)

Hi Zazza,

 

To make it so that Excel does not pop up, you can change the state from "normal" to "minimized" or "no change", whichever you like better. 

 

If you use "Save report to file" before "dispose report", then it will not ask you if you want to save it. "Dispose report" has an input on the bottom to close the report, which defaults to true, but since you have not saved the file yet you are getting a dialog as it tries to close Excel.

0 Kudos
Message 3 of 16
(3,932 Views)

Here find attached the full VI. Please bear in mind that is written by a two-week LabVIEW user..

I tried to implement both answer you gave me but I run into an error on the save to file VI.

Apologize for the stupid question.

 

Thank you for your help.

0 Kudos
Message 4 of 16
(3,924 Views)

Hi Zazza, what error are you receiving?

0 Kudos
Message 5 of 16
(3,918 Views)

We all started somewhere. No question is a stupid question.

0 Kudos
Message 6 of 16
(3,911 Views)

Here is the screenshot of the error I got.
I got rid of the error only if I remove the Save Report to File VI and if in the Dispose report I put a "true" value in the "Save changes" node. The only thing is that LabVIEW doesn't pop-up the windows where it asks to enter filename and directory, but it is hide behind the front panel and block diagram windows.
My intention would be the following: once the user press "save as" and then click "save" on the two button dialog, the VI automatically pop-up the windows explorer to let user decide filename and directory to save the Excel file.

Thank you again for your help.

0 Kudos
Message 7 of 16
(3,875 Views)

There's a pretty good Example on using the RGT to Generate an Excel Report that can be found here in the Forum -- do a search for "Revised Generate " and see what pops up when you type those two words in the Forum's Search bar.  I know the author ...

 

Some comments on your code, designed to give you some pointers on writing better LabVIEW code:

  • Use the Error Line!  A While Loop should have a Shift Register with the Error Line on it, and functions (such as the RGT Series) should "sit" on that line.  If your code throws an error, you generally want to know and stop it from running.
  • Don't hide the labels on your Controls and Indicators on the Block Diagram!  I went looking for "Data" -- it's the (unlabeled) String Array indicator in the upper right-hand corner of the While Loop.
  • Why are you deciding every loop on writing data?  The logic seems strange here -- shouldn't you acquire/process, then decide whether or not to save?  I.e. shouldn't these be sequential, not simultaneous?  [If you want to do it simultaneously, there are ways, but you may not be ready for them ...].
  • The RGT logic:
    • The RGT uses Excel, so Excel has to be running.  You don't, however, have to see it -- just start it Minimized (not "no change").
    • I suggest you decide in advance the file path for the .xlsx file and wire it into the Save Report function (it does need a file argument).
    • Dispose Report will stop Excel.  Note that after you do the Write, you stop the loop.  This means you can easily decide to Stop the loop, then take the data (carried in the pink shift register at the top) and wire it in (without using Local Variables, a dangerous thing for beginners to use, trust me).  I didn't notice that this directly addresses the question I asked just before this section -- simply move the RGT code to the outside of your While Loop.
  • Sometimes when you have problems with one part of the code (the RGT, for example), a good thing to try is to make a copy of your code and isolate the part to test.  Take the RGT code by itself, generate a small Data array, make a suitable File Path, and just try creating the Excel file (with the changes I suggested).  If in doubt, look up and study the Example I mentioned at the top.

Bob Schor

0 Kudos
Message 8 of 16
(3,847 Views)

Hi Zazza, it seems like a pretty generic error, maybe you are feeding the "save" VI an invalid path? Can you post your code for 2016 or a snippet of it?

0 Kudos
Message 9 of 16
(3,843 Views)

@Bob_Schor wrote:
    • The RGT uses Excel, so Excel has to be running.  You don't, however, have to see it -- just start it Minimized (not "no change").

Hi Bob,

 

I'm using Win10, Excel 2013, and LV 2016. I like "no change" because it doesn't even appear to the user that Excel is being opened. But I can open up the Excel file afterward and verify that some text was written. If I use "minimized" and Excel is not open yet, I get an error. I use "minimized" and Excel is open, it minimizes my current workbook, does it's work, then open my workbook again, which is kind of annoying. I think it works differently on different systems though.

0 Kudos
Message 10 of 16
(3,840 Views)