cancel
Showing results for 
Search instead for 
Did you mean: 

How to export graph into excel

Former Member
0 Kudos

Hi All,

(Powerbuilder 12.5 classic)

I have a datawindow with graph in and I wish to export the graph to excel, possible?

Currently, it will only export the excel data without the graph.

Please advise.

Thank you in advance.


Regards,

Yow


Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Yow;

  FYI:  As Rene suggests, you can use the Clipboard () method to get the graph. The other ways to get a visual representation of the graph are:

1) Use the SaveAs ( ) method with the Clipboard option.

  ie:   DC.SaveAs ( "",  Clipboard!, False )

- or -

2) Use the SaveAs ( ) method with the WMF option.

  ie:   DC.SaveAs ( "MyGraph.wmf",  WMF!, False )

  Either way, you now have to use OLE to get the file or clipboard content into the Excel spreadsheet or pop-up a message-box to the business user to paste the file or clipboard into spreadsheet where they need it.

Regards ... Chris

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi All,

Need further help here. Still cannot save the graph as image in excel.

I have code as below on click function of "Generate" button.

string ls_docname, ls_named

integer  li_value

oleobject        lole_excel

lole_excel = CREATE OLEObject

lole_excel.ConnectToNewObject( "excel.application" )

lole_excel.visible = true

dw_1.SaveAs('Graph.wmf',wmf!,TRUE)

lole_excel.workbooks.open("C:\.....reports\Graph.wmf")

lole_excel.Selection.Copy()

li_value = GetFileSaveName("Select File", &

    ls_docname, ls_named, "DOC", &

  "Excel Workbook (*.xlsx),*.xlsx" )

  

IF li_value = 1 THEN

   dw_1.SaveAs(ls_docname,XLSX!,TRUE)

END IF

lole_excel.workbooks.close()

lole_excel.disconnectobject()

DESTROY lole_excel

After click on the "Generate" button, it will first prompt an excel with something like graph result as below:

But, after save it into excel file, it will generate the graph excel data as below, and not the graph image as expected:

Please help.

Thank you.

Regards.

Yow

Former Member
0 Kudos

Hi Yow,

you can't open a wmf file in excel with workbooks.open(). You have to import the image file into a worksheet.

Not tested example: (creates a new workbook and inserts the image)

lole_excel = CREATE OLEObject

lole_excel.ConnectToNewObject( "excel.application" )

lole_excel.visible = true

lole_excel.workbooks.add()

lole_sheet = lole_excel.ActiveSheet

dw_1.SaveAs('C:\.....reports\Graph.wmf',wmf!,TRUE)

lole_sheet.Shapes.addPicture("C:\.....reports\Graph.wmf", 0, -1, left, right, width, height)

see excel vba documentation for more information

Former Member
0 Kudos

You can copy the graph image to clipboard (SyBooks Online) and the insert it into a excel file (e.g. using ole automation).