PowerBuilder Function Export/Copy Data From DataStore/DataWindow To Excel gf_copy_datastore_to_excel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
///////////////////////////////////////////////////////////////////////////////////////////////////////////// // // Function Name : gf_copy_datastore_to_excel // Argument Name : apo_dwo, Arg Type : PowerObject, Pass By : Value // Return Type : Integer /////////////////////////////////////////////////////////////////////////////////////////////////////////////// datawindow ldw_control datastore lds_control Integer li_i OleObject obj_excel_appl OleObject obj_excel_workbook If apo_dwo.TypeOf() = datawindow! Then ldw_control = apo_dwo li_i = ldw_control.SaveAs('', Clipboard!, True) ElseIf apo_dwo.TypeOf() = datastore! Then lds_control = apo_dwo li_i = lds_control.SaveAs('', Clipboard!, True) Else MessageBox('Error', 'Invalid Object.', Exclamation!) li_i = -1 End If If li_i = 1 Then obj_excel_appl = Create OleObject If obj_excel_appl.ConnectToObject('', 'excel.application') = 0 Then obj_excel_workbook = obj_excel_appl.Workbooks.Add() obj_excel_appl.ActiveSheet.Paste() MessageBox('Done', 'Data is copied to workbook "' + & String(obj_excel_workbook.Name) + & '"', information!) Else MessageBox('Error', 'Ms Excel is not running.', Exclamation!) li_i = -1 End If Destroy obj_excel_appl End If Return li_i |
Good Luck!
Subscribe
Login
0 Comments