LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get image from Excel graph

Hi,

 

I'm creating an Excel report with graph and I would like to save an image of the graph to jpg, gif or bmp format.

 

I tried with VBA code, ActiveX but no result...

 

I have the report generation toolit, LV 2009 and Excel 2007.

 

Thanks.

0 Kudos
Message 1 of 9
(3,845 Views)

Hi!

 

Does the Excel report create the graph or do you have the same graph in your VI in LabVIEW? 

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 2 of 9
(3,838 Views)

Hello,

 

Excel create the Graph.

 

Thanks.

 

0 Kudos
Message 3 of 9
(3,836 Views)

Hi Carcasse,

After you have created the graph you can call the method Export under the Chart object in Excell structure.

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 4 of 9
(3,829 Views)

Maybe this can help also

Regards,
Even
_________________________________
Certified LabVIEW Associate Developer

Automated Test Developer
Topro AS
Norway
0 Kudos
Message 5 of 9
(3,827 Views)

Hello,

 

@g_Ricky: Thank you.

 

How I can create the chart object reference ?

 

Sorry but i'm a beginner's with Excel ActiveX...

 

@Even Deejay : Thanks for the link I will download the example and llb.

0 Kudos
Message 6 of 9
(3,823 Views)

to create the reference to the excell chart obj, simply you click with the right button on the automation refnum connection of the function Automation Open then select from the menu create --> constant. A constant will be connected to the refnum input then click on the constant with the right buttons of the mouse and select Select ActiveX class --> browse, a window will open and there you have to choose the reference of Excell application you want to use, or as I did in my immage a reference of Microsoft graph object.

Ricky
Italian Developer engineer
www.www.selt-sistemi.com
0 Kudos
Message 7 of 9
(3,819 Views)

Hello,

 

Thanks, but your solution reporting an error with no description,

 

but i found VBCode and he working with 97,2003 and 2007.

 

Only one problem : I can not run the code from the function available in LV maybe a problem with my diagram.

 

The working code : He can help anyone.



Spoiler
Option ExplicitSub ExportChart() ' Export a selected chart as a pictureConst sSlash$ = "/" Const sPicType$ = ".gif" Dim sChartName$ Dim sPath$ Dim sBook$ Dim objChart As ChartObject On Error Resume Next' Test if there are even any embedded charts on the activesheet' If not, let the user knowSet objChart = ActiveSheet.ChartObjects(1) If objChart IsNothingThen MsgBox "No charts have been detected on this sheet", 0 Exit SubEndIf' Test if there is a single chart selectedIf ActiveChart IsNothingThen MsgBox "You must select a single chart for exporting ", 0 Exit SubEndIf Start: sChartName = Application.InputBox("Please Specify a name for the exported chart" & vbCr & _ "There is no default name available" & vbCr & _ "The chart will be saved in the same folder as this file", "Chart Export", "") ' User presses "OK" without entering a nameIf sChartName = Empty Then MsgBox "You have not entered a name for this chart", , "Invalid Entry" Goto Start EndIf' Test for Cancel buttonIf sChartName = "False" Then Exit SubEndIf' If a name was given, chart is exported as a picture in the same' folder location as their current file sBook = ActiveWorkbook.Path sPath = sBook & sSlash & sChartName & sPicType ActiveChart.Export Filename:=sPath, FilterName:="GIF"  

 

0 Kudos
Message 8 of 9
(3,803 Views)

Hello Carcasse,

 

I think you can use this exemple export excel graph and then import the graph in LabVIEW using an activeX container (control palette .NET and activeX).

 

Unfortunately, the VI will not run with newer versions of the report generation toolkit. Luckily, the only portion of the code that is broken is the part that obtains the reference to the spreadsheet, which should be fairly trivial to re-write. The part that will help you however, is all of the property nodes in the Excel Export Graph.vi. The property nodes used here illustrate how to copy a graph from an excel spreadsheet to the clipboard.

 

Sincerely

Romain DUVAL || RF & Semiconductor Staff System Engineer || CLA || CTA
National Instruments France

0 Kudos
Message 9 of 9
(3,780 Views)