Form VL_SAM082: MS-Excel Integration
Name: VL_SAM082
Description: The following RDMLX form is used to demonstrate how information can be written to and read from a MS-Excel spreadsheet. This form uses reusable component VL_SAM083.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(384) LEFT(342) TOP(131) WIDTH(476);
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID) COLUMNBUTTONHEIGHT(18) DISPLAYPOSITION(1) HEIGHT(313) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TOP(0) WIDTH(377);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_1) CAPTION('Number') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#GRID) SOURCE(#EMPNO) WIDTH(15);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_2) CAPTION('First Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#GRID) SOURCE(#GIVENAME) WIDTH(30);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_3) CAPTION('Last Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(3) PARENT(#GRID) SOURCE(#SURNAME) WIDTH(30);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_4) CAPTION('Salary') CAPTIONTYPE(Caption) DISPLAYPOSITION(4) PARENT(#GRID) SOURCE(#SALARY) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#TO_XLS) CAPTION('----> XL') DISPLAYPOSITION(2) HINT('Send to XL SpreadSheet') LEFT(384) PARENT(#COM_OWNER) TABPOSITION(2) TOP(3) WIDTH(81);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#FROM_XLS) CAPTION('<---- XL ') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(28) HINT('Receive from XL SpreadSheet') LEFT(384) PARENT(#COM_OWNER) TABPOSITION(3) TOP(32) WIDTH(81);
DEFINE_COM CLASS(#VL_SAM083) NAME(#OS) DISPLAYPOSITION(4) LEFT(592) PARENT(#COM_OWNER) TABPOSITION(4) TOP(464) VISIBLE(False);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(5) HEIGHT(25) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(5) TOP(332) WIDTH(468);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Use Format') DISPLAYPOSITION(6) HEIGHT(73) LEFT(384) PARENT(#COM_OWNER) TABPOSITION(6) TABSTOP(False) TOP(64) WIDTH(81);
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RB_DBF) BUTTONCHECKED(True) CAPTION('DBF') DISPLAYPOSITION(1) LEFT(8) PARENT(#GPBX_1) TABPOSITION(1) TOP(13) WIDTH(56);
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RB_TAB) CAPTION('Tab') DISPLAYPOSITION(2) LEFT(8) PARENT(#GPBX_1) TABPOSITION(2) TOP(39) WIDTH(49);
;
Define #FileName *char 100;
Define #FileForm *char 1 ;
Define #RetCode *char 2;
Define #osErrCode RefFld(#Std_Num);
;
EVTROUTINE handling(#com_owner.Initialize);
Set #RB_TAB ButtonChecked(True);
Change #FileForm T ;
Invoke #OS.MakeTempFileName iSuffix(XLS) iNamePart1(*Component) iNamePart2('Employees') oFileName(#FileName) ;
Select Fields(#Empno #SurName #GiveName #Salary) From_File(PslMst);
Add_Entry #Grid;
EndSelect ;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#TO_XLS.Click);
Use Builtin(Transform_List) with_args(#Grid #FileName #FileForm) to_get(#RetCode);
if '#RetCode = OK';
Set #From_XLS Enabled(True);
Invoke #OS.ExecuteFile iFileName(#FileName) oRetCode(#osErrCode) ;
Endif ;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#FROM_XLS.Click);
Clr_list #Grid;
Use Builtin(Transform_File) with_args(#Grid #FileName #FileForm) to_get(#RetCode);
ENDROUTINE ;
;
EVTROUTINE HANDLING(#RB_DBF.Click #RB_TAB.Click);
if '#Rb_Tab.ButtonChecked = True';
Change #FileForm T;
endif ;
if '#Rb_Dbf.ButtonChecked = True';
Change #FileForm B;
endif ;
ENDROUTINE ;
END_COM ;
Name: VL_SAM082
Description: The following RDMLX form is used to demonstrate how information can be written to and read from a MS-Excel spreadsheet. This form uses reusable component VL_SAM083.
FUNCTION OPTIONS(*DIRECT);
BEGIN_COM FORMPOSITION(ScreenCenter) HEIGHT(384) LEFT(342) TOP(131) WIDTH(476);
DEFINE_COM CLASS(#PRIM_GRID) NAME(#GRID) COLUMNBUTTONHEIGHT(18) DISPLAYPOSITION(1) HEIGHT(313) LEFT(0) PARENT(#COM_OWNER) TABPOSITION(1) TOP(0) WIDTH(377);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_1) CAPTION('Number') CAPTIONTYPE(Caption) DISPLAYPOSITION(1) PARENT(#GRID) SOURCE(#EMPNO) WIDTH(15);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_2) CAPTION('First Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(2) PARENT(#GRID) SOURCE(#GIVENAME) WIDTH(30);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_3) CAPTION('Last Name') CAPTIONTYPE(Caption) DISPLAYPOSITION(3) PARENT(#GRID) SOURCE(#SURNAME) WIDTH(30);
DEFINE_COM CLASS(#PRIM_GDCL) NAME(#GDCL_4) CAPTION('Salary') CAPTIONTYPE(Caption) DISPLAYPOSITION(4) PARENT(#GRID) SOURCE(#SALARY) WIDTH(20) WIDTHTYPE(Remainder);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#TO_XLS) CAPTION('----> XL') DISPLAYPOSITION(2) HINT('Send to XL SpreadSheet') LEFT(384) PARENT(#COM_OWNER) TABPOSITION(2) TOP(3) WIDTH(81);
DEFINE_COM CLASS(#PRIM_PHBN) NAME(#FROM_XLS) CAPTION('<---- XL ') DISPLAYPOSITION(3) ENABLED(False) HEIGHT(28) HINT('Receive from XL SpreadSheet') LEFT(384) PARENT(#COM_OWNER) TABPOSITION(3) TOP(32) WIDTH(81);
DEFINE_COM CLASS(#VL_SAM083) NAME(#OS) DISPLAYPOSITION(4) LEFT(592) PARENT(#COM_OWNER) TABPOSITION(4) TOP(464) VISIBLE(False);
DEFINE_COM CLASS(#PRIM_STBR) NAME(#STBR_1) DISPLAYPOSITION(5) HEIGHT(25) LEFT(0) MESSAGEPOSITION(1) PARENT(#COM_OWNER) TABPOSITION(5) TOP(332) WIDTH(468);
DEFINE_COM CLASS(#PRIM_GPBX) NAME(#GPBX_1) CAPTION('Use Format') DISPLAYPOSITION(6) HEIGHT(73) LEFT(384) PARENT(#COM_OWNER) TABPOSITION(6) TABSTOP(False) TOP(64) WIDTH(81);
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RB_DBF) BUTTONCHECKED(True) CAPTION('DBF') DISPLAYPOSITION(1) LEFT(8) PARENT(#GPBX_1) TABPOSITION(1) TOP(13) WIDTH(56);
DEFINE_COM CLASS(#PRIM_RDBN) NAME(#RB_TAB) CAPTION('Tab') DISPLAYPOSITION(2) LEFT(8) PARENT(#GPBX_1) TABPOSITION(2) TOP(39) WIDTH(49);
;
Define #FileName *char 100;
Define #FileForm *char 1 ;
Define #RetCode *char 2;
Define #osErrCode RefFld(#Std_Num);
;
EVTROUTINE handling(#com_owner.Initialize);
Set #RB_TAB ButtonChecked(True);
Change #FileForm T ;
Invoke #OS.MakeTempFileName iSuffix(XLS) iNamePart1(*Component) iNamePart2('Employees') oFileName(#FileName) ;
Select Fields(#Empno #SurName #GiveName #Salary) From_File(PslMst);
Add_Entry #Grid;
EndSelect ;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#TO_XLS.Click);
Use Builtin(Transform_List) with_args(#Grid #FileName #FileForm) to_get(#RetCode);
if '#RetCode = OK';
Set #From_XLS Enabled(True);
Invoke #OS.ExecuteFile iFileName(#FileName) oRetCode(#osErrCode) ;
Endif ;
ENDROUTINE ;
;
EVTROUTINE HANDLING(#FROM_XLS.Click);
Clr_list #Grid;
Use Builtin(Transform_File) with_args(#Grid #FileName #FileForm) to_get(#RetCode);
ENDROUTINE ;
;
EVTROUTINE HANDLING(#RB_DBF.Click #RB_TAB.Click);
if '#Rb_Tab.ButtonChecked = True';
Change #FileForm T;
endif ;
if '#Rb_Dbf.ButtonChecked = True';
Change #FileForm B;
endif ;
ENDROUTINE ;
END_COM ;