LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Save excel chart as image (activeX)

Solved!
Go to solution

Hi community,

 

I have to generate couple thousands xls files which have some data and a chart on the first sheet. Once the files are generated I'd like to sweep thru all of them and save the chart as an image (BMP, GIF, PNG, doesnt matter).

 

I have no success though. I assume I am quite close, by using the Chart.export method, but actually nothing happens, the file is not created. (worksheet selection is good, and chart index must be one, as 0 or 2 gives me an error message while one is OK.

 

Any ideas?

thx.

 

ps: i know how to export an image of a labview-chart, but I want the export to happen from excel..

 

x.png

0 Kudos
Message 1 of 13
(5,787 Views)

Is the chart an embedded chart or a chart sheet?

0 Kudos
Message 2 of 13
(5,775 Views)

Right now the chart is part of sheet1 (so its next to the data columns), but the ultimate goal is to have in on a chart sheet.

0 Kudos
Message 3 of 13
(5,772 Views)

Do you get an error message?

 

Ben64

0 Kudos
Message 4 of 13
(5,760 Views)

The problem is that the worksheet ChartObjects method do not return an Excel._Chart object but an Excel.ChartObject object. Change the ActiveX class from Excel._Chart  to Excel.ChartObject (the chartObject contain the actual chart) and use a property node to get the reference to the chart. You can then use this reference to export the chart image.

 

Ben64

 

Excel export chart method.png

Message 5 of 13
(5,732 Views)

Works wonderful! Can you tell me how can I do the same if the chart is not embedded into a worksheet, but it is on a separate chart tab in excel?

0 Kudos
Message 6 of 13
(5,689 Views)
Solution
Accepted by topic author 1984

Instead of getting a reference to the workbook worsheets collection you need to get a reference to the workbook charts collection (which is the collection of all the workbook chartsheets) . You select the chart sheet using its index and convert the resulting item to an Excel._Chart object (this is where you use this object). You can then export it.

 

Ben64

 

Excel export chartsheet method.png

Message 7 of 13
(5,681 Views)

Thanks mate! You helped a lot!

0 Kudos
Message 8 of 13
(5,678 Views)

@1984 wrote:

Thanks mate! You helped a lot!


If you are going to be doing any more of this work with ActiveX and Excel in LabVIEW, get yourself familiar with the

Excel Developer Reference http://msdn.microsoft.com/en-us/library/ee861528%28v=office.14%29

Message 9 of 13
(5,614 Views)

nyc a écrit :

@1984 wrote:

Thanks mate! You helped a lot!


If you are going to be doing any more of this work with ActiveX and Excel in LabVIEW, get yourself familiar with the

Excel Developer Reference http://msdn.microsoft.com/en-us/library/ee861528%28v=office.14%29


Thanks for sharing this usefull link nyc, I always end up in the MSDN site but never throught the front door.

 

Ben64

0 Kudos
Message 10 of 13
(5,601 Views)