Steve Morris Posted December 26, 2014 Report Share Posted December 26, 2014 I have an application that uses the report generation functions to write test data into an Excel file. I've set it up to open Excel minimized, but I'd like to run Excel in the background or 'hidden' so that the operator can't accidently close the file during the test run. Does anyone know how to do this? Quote Link to comment
Gribo Posted December 27, 2014 Report Share Posted December 27, 2014 Check the Excel .NET API reference from Microsoft. The application object has an option to start hidden. 1 Quote Link to comment
Steve Morris Posted December 30, 2014 Author Report Share Posted December 30, 2014 Gribo, Thanks for the reply, unfortunately I can't find an Excel .NET API from Microsoft. If I drop a .NET constructor node on my block diagram and go to select an assembly, the only Excel one I can find is Microsoft.Office.Interop.Excel and it's application object has no public items. I've tried searching the web for an Excel .NET API and can't find anything from Microsoft other than what I already have. I must be looking in the wrong places, can you point me in the right direction? Steve Quote Link to comment
martin_g Posted December 30, 2014 Report Share Posted December 30, 2014 If you open up one of the Excel Report Toolkit VIs, you'll see the .NET functions being used. 1 Quote Link to comment
Yair Posted December 31, 2014 Report Share Posted December 31, 2014 The RGT uses ActiveX, not .NET. There's a thread with Excel examples here, and I assume at least some of the newer ones are probably with the .NET API - http://forums.ni.com/t5/BreakPoint/Excel-Board/m-p/379682#M2391 Looking at your OP, I see that you're using the RGT. It has a VI which returns the Excel ActiveX references. You should be able to use that to get the Application reference and set it to hidden (I think there's a Visible property, but I didn't really play much with it, so I don't remember for sure that I even did this). 1 Quote Link to comment
Steve Morris Posted December 31, 2014 Author Report Share Posted December 31, 2014 Gribo, martin_g and Yair, Thanks for the help. Indeed in the guts of the RGT's New Report.vi is a Visible property that allows you to run 'hidden' if you set it to False. One good and bad thing about it is that it just works for the file that you open with the RGT. Good because you don't have to reset it to True to use Excel once you are finished with it in LabVIEW. Bad because if you open any other Excel file, outside of LV, while you are using the 'hidden' one in LV, the hidden one is no longer hidden. I don't know if this will be enough security for this application (if an operator were to stumble through to the active Excel file and close it we could lose a couple days of test data), but it is good to know. Thanks again. Quote Link to comment
Yair Posted December 31, 2014 Report Share Posted December 31, 2014 I don't know if this will be enough security for this application (if an operator were to stumble through to the active Excel file and close it we could lose a couple days of test data), but it is good to know. I would strongly suggest NOT using Excel to save your data. Pick a method to save your data (examples include a simple binary file, TDMS, CSV files, databases, etc.) and if you want to see the data in Excel, export a copy of the data to a format that Excel understands. That way, your data will not be dependent on what the user does. 2 Quote Link to comment
CRoebuck Posted January 2, 2015 Report Share Posted January 2, 2015 Using the ActiveX API can yield some odd behaviour if you then "manually" interact with Excel, launching another instance for example. If you have long running tests then I suggest that streaming to Excel is not ideal. Might be better to write to a database or TDMS file and then arrange for the data to be exported in an appropriate manner. Remember there are size limitations to the number of rows you can have depending on your Excel version, again worth consideration. All that being said, if I can help with the Excel API then just ask Chris Quote Link to comment
Steve Morris Posted January 4, 2015 Author Report Share Posted January 4, 2015 The end user requires Excel in this case. I think what I'll end up doing is saving everything in csv format while the test is underway and write it all into the Excel template when the test completes. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.