Powerbuilder Data Window Turn Microsoft Excel, Word Program Source Code

zhaozj2021-02-08  227

Powerbulider Data Window Turn Microsoft Execl, Word Program Source Code

A, f_cncharnum function f_cncharnum.srf $ PBExportHeader $ f_cncharnum.srf $ PBExportComments $ kanji character string or obtained in double-byte number of global type f_cncharnum from function_objectend typeforward prototypesglobal function integer f_cncharnum (string aString) end prototypesglobal function integer f_cncharnum (string aString ); // function name: f_cncharnum // Uses: Returns a number of characters in a string // input: astring - string, given strings // return value: li_num - integer, a given string Chinese characters Number // Note: 1. This method is based on the effectiveness of Chinese characters of Chinese standard Chinese character library zone coding, which does not meet this code is ineffective! // 2. If the Chinese character string contains non-Chinese characters, such as graphic symbols or ASCII codes, these non-Chinese characters will remain unchanged .// Unit string ls_secondsectable // Store all national standard secondary Chinese characters pronunciation integer li_num = 0 // Return value I, JFOR i = 1 to len (astring) LS_CH = MID (astring, i, 1) IF ASC (LS_CH)> = 128 THEN / / is Chinese character Li_NUM i = i 1END IFNEXTRETURN LI_NUMEND FUNCTION

Second, PBTOEXCEL function f_outputtoExcel_new.srf

$ PBExportHeader $ f_outputtoexcel_new.srfglobal type f_outputtoexcel_new from function_objectend typeforward prototypesglobal function integer f_outputtoexcel_new (datawindow adw) end prototypesglobal function integer f_outputtoexcel_new (datawindow adw); // function name: f_outputtoexcel_new // Input: adw - datawindow, specify the data window // returns value: Integerconstant integer ppLayoutBlank = 12OLEObject ole_objectole_object = CREATE OLEObjectinteger li_retli_ret = ole_object.ConnectToObject ( "", "Excel.Application") IF li_ret <> 0 tHEN // Excel if not already open, the new.

li_ret = ole_object.ConnectToNewObject ( "Excel.Application") if li_ret <> 0 thenMessageBox ( 'OLE errors', 'OLE not connect Error Number:!' string (li_ret)) return 0end ifole_object.Visible = TrueEND IFpointer oldpointeroldpointer = SetPointer (HourGlass!) ole_object.Workbooks.Addlong ll_colnum, ll_rownumstring ls_valuestring ls_objects, ls_obj, ls_objs [], ls_objtag [] long ll_pos, ll_len, ll_num = 0ls_objects = trim (adw.Describe ( 'datawindow.Objects')) do while (pos (Ls_Objects, "~ T")> 0) LL_POS = POS (Ls_Objects, "~ T") LL_LEN = LL_POS - 1LS_OBJ = Left (Ls_Objects, LL_LEN) IF (Adw.Describe (ls_obj '.type') = 'column 'or & adw.describe (ls_obj ' .type ') =' compute ') And & & & & & (Adw.describe (Ls_Obj ' .band ') =' DETAIL ') AND (Ls_Obj <> "ASD") Thenll_num = 1LS_OBJS [ll_num] = ls_objls_objtag [ll_num] = adw.describe (ls_obj '.tag') end ifls_objects = right (ls_objects, len (ls_objects) - ll_pos) loop // The number of columns and rows of data window data (number of lines Should be the number of data lines 1) ll_colnum = ll_numll_rownum = adw.rowcount () 1String Ls_colnameinteger i, j, kfor i = 1 to ll_colnum // Get the name of the title header LS_Value = Ls_objtag [i] ole_object.cells (1, i) .value = ls_valuenextstring column_namefor i = 2 to ll_rownumfor j = 1 to ll_colnumcolumn_name = ls_objs [j] if adw.Describe (column_name '.type') = 'column' thenls_value = adw.describe ("Evaluate (" colorupdisplay (" color (i - 1) ") ")") ")") ")") ")") ")") = 'compute' Thenls_Value = = COMPUTE 'THENLS_VALUE =

Adw.describe ("Evaluate ('" adw.describe (coloruMn_name ' .expression ') "") ")") ") End ifole_Object.cells (i, j) .value = ls_valuenextnextSetPointer (oldpointer) ole_object.disconnectobject () DESTROY ole_objectreturn 1end function three, PBToWord function f_outputtoword_new.srf $ PBExportHeader $ f_outputtoword_new.srfglobal type f_outputtoword_new from function_objectend typeforward prototypesglobal function integer f_outputtoword_new (datawindow adw) end prototypesglobal function integer f_outputtoword_new (datawindow adw); / / function name: f_outputtoword_new // input: adw - datawindow, specified data window // return value: Integerconstant integer ppLayoutBlank = 12OLEObject ole_objectole_object = CREATE OLEObjectinteger li_retli_ret = ole_object.ConnectToObject ( "", "word.application") IF li_ret <> 0 THEN/ If Word has not been opened, then new.

li_ret = ole_object.ConnectToNewObject ( "word.application") if li_ret <> 0 thenMessageBox ( 'OLE errors', 'OLE not connect Error Number:!' string (li_ret)) return 0end ifole_object.Visible = TrueEND IFlong ll_colnum, ll_rownumconstant long wdWord9TableBehavior = 1constant long wdAutoFitFixed = 0constant long wdCell = 12string ls_valuepointer oldpointeroldpointer = SetPointer (HourGlass!) string ls_objects, ls_obj, ls_objs [], ls_objtag [] long ll_pos, ll_len, ll_num = 0ls_objects = trim (adw.Describe ( 'datawindow. Objects')) DO While (POS (Ls_Objects, "~ T")> 0) LL_POS = POS (Ls_Objects, "~ T") LL_LEN = LL_POS - 1LS_OBJ = Left (Ls_Objects, LL_LEN) IF (ADW.Describe (ls_obj '.Type ') =' column 'or & adw.describe (ls_obj ' .type ') =' compute ') And & & & & & & & (Adw.describe (Ls_Obj ' .band ') =' Detail ') And (ls_obj <> "asd") thenll_num = 1ls_objs [ll_num] = ls_objls_objtag [ll_num] = adw.Describe (ls_obj '.tag') end ifls_objects = right (ls_objects, len (ls_objects) - ll_pos) loop // get the data window data The number of columns and lines (the number of lines should be the number of data lines 1) LL_COLNUM = LL_NUMLL_ROWNUM = Adw.Rowcount () 1 ole_object.Documents.Add () ole_object.ActiveDocument.Tables.Add (ole_object.Selection.Range, ll_rownum, ll_colnum) string ls_colnameinteger i, j, kfor i = 1 to ll_colnum // give the title name of the header ls_value = ls_objtag [i] ole_object.Selection.TypeText (ls_value) for k = 1 to f_cncharnum (ls_value) ole_object.Selection.TypeBackspace () nextole_object.Selection.MoveRight (wdCell) nextadw.setredraw (false) ole_object.Selection.MoveLeft (wdCell) string column_namefor i = 2 to LL_ROWNUMFOR J =

转载请注明原文地址:https://www.9cbs.com/read-1793.html

New Post(0)