Written using LV2014 64bit, this WriteExcelChart.zip VIs on the forum thread do the following:
"OpenMSExcel" - open Excel then adds an unused sheet.
"WriteExcel" - takes a 2D array (or 1D), creates a new sheet if the name does not exist or to named sheet, writes the data to Excel sheet.
"'WriteExcelChart" - same as above but adds option to plot the Excel data using your chart type. Both WriteExcel VIs are reentrant this way your able to run seperate code modules that continue writing where the last write line ended. This VI will have some code I stripped out, modify as needed.
"ExcelRefsGetSet" - action engine caches references, no need to wire Excel VIs in your code.
"CloseExcelRef" - must use to close Excel reentrants refs when done.
Now that it looks like Microsoft deprecated ActveX Automation interface in Excel 2016, the only other interface left is through .NET interop assemblies. I have tried to reproduce Excel - Write Table.vi using .NET instead of ActiveX. The result of the effort is attached. There is a big problem though: the 'To .NET Object.vi' doesn't accept a 2D array of variants which the Range.value2 property when using ActiveX could without a problem! So, say getting a recordset from a database and then writing it as it is to a new Excel workbook is no longer possible as far as I understand. This is really sad. A 2D Table of strings or doubles is OK. So, if you need to use those, you can with the attached code
OK, so ActiveX still works in Excel 2016. But it is older than .NET and they can still deprecate it in the next version. So, experience on how to communicate with Excel via .NET can become very valuable.
So what? LAVA is LAVA, NI Forums have not exactly the same audience. Otherwise why would both need to exist?
There are many of us on both LAVA and the NI Forums. Besides, the crossposting is just showing people another place where the discussion is happening, hopefully adding value in both locations.
Oh, sorry. I thought you were objecting crossposting. But you just pointed to where else it is discussed.
Yup, not criticizing, just trying to help those taking place in the conversation, the similar discussion taking place elsewhere.
Like many others, I was looking for a "simple" way to get spreadsheet data from an Excel doc into LabVIEW. This board was very helpful in getting me started. Unfortunately, every time I thought I had a stable solution, a new problem would crop up. Issues such as:
How to get all the contents of the sheet.
How to change workbook pages.
What if Excel is already open. Closing it programatically would appear strange to the enduser.
What if Excel has the target spreadsheet already open. Once again, closing it might be bad.
An error can lead to an open hidden instance of Excel.
I've attached my sub-VI which takes from many other examples to create a single sub-VI solution. I'm an absolute ActiveX novice, so hopefully I've got it right!
This example will check to see if Excel is already open and not close it if it is. It will also check to see if the target workbook is already open and not close it if it is; but close it if it is not. Also, in the event of an error, this VI will kill the Excel task to prevent a hidden background instance of Excel.