BreakPoint

cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Board

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.

 

Rich J

0 Kudos
Message 81 of 91
(11,353 Views)

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

Message 82 of 91
(10,650 Views)
0 Kudos
Message 83 of 91
(10,606 Views)

So what? LAVA is LAVA, NI Forums have not exactly the same audience. Otherwise why would both need to exist?

0 Kudos
Message 84 of 91
(10,592 Views)

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.

Message 85 of 91
(10,591 Views)

@styrum wrote:

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 86 of 91
(10,585 Views)

Oh, sorry. I thought you were objecting crossposting. But you just pointed to where else it is discussed.

0 Kudos
Message 87 of 91
(10,581 Views)

@styrum wrote:

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.

 

Unofficial forum guidelines

 

  • If you want to ask the same question on another LabVIEW board like LAVA, feel free to do so.  One thing that helps collaborate efforts is to provide a link in your post back to the other place where the question was asked.  This way someone on the NI forums can see what has already been said on another forum.  This is known as a crosspost.
Message 88 of 91
(10,546 Views)

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.

 

...Mike

Message 89 of 91
(9,843 Views)

This is the same Excel Read.vi, but saved in LabVIEW 2013.  In my previous post, it was saved in 2014.

Message 90 of 91
(9,610 Views)