Schultz’s PowerBuilder Notes

Adding “Export to Excel” Menu item

Add a menu item under FUNCTIONS which exports a datawindow to excel. This example assumes PFC is being used.


Add the item Functions > Export to Excel




Enabled = FALSE


Your main sheet ancestor

  • Instance Variables


u_dw idw_export

  • ue_export

// Event: w_sheet_lm:ue_export
// Description: export the registered datawindow (idw_export) to excel

if IsValid(idw_export) then
. idw_export.SaveAs(“”, Excel5!, TRUE)
end if

How to use

  1. In the Activate Event of the sheet, enable the menu item EXPORT
  2. In the Deactivate Event of the sheet, disable the menu item EXPORT
  3. In the window pfc_preopen event, associate the datawindow you wish to export to idw_export
  4. If you want to do something trickier, for example, you want to allow the user to select one of several different datawindows to export, override the sheet’s UE_EXPORT event.

April 15, 2008 - Posted by | Menus | , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: