ExcelService

Refer to shipped RPG source file QRPGLRSRC and CRTDEMO program source in QCLSRC source file.

      *

      * V6R1 - Limits

      * Maximum data structure size is 16,773,104 bytes

      * Data structure size = element size * occurrence

      *

     D ListDef1        S             60    DIM(3) CTDATA

     D ListDefSize     S             10I 0 INZ(0)

     D ListEntSize     S             10I 0 INZ(0)

     D ListCount       S             10I 0 INZ(0)

     D ListMaxCount    S             10I 0 INZ(0)

      *

     D JSMHDL          S              4    INZ(*BLANKS)

     D JSMSRV          S            100    INZ(*BLANKS)

     D JSMSTS          S             40    INZ(*BLANKS)

     D JSMMSG          S           4096    INZ(*BLANKS)

     D JSMCMD          S           2048    INZ(*BLANKS)

     D ZEROLENGTH      S             10I 0 INZ(0)

      *

     D COUNT           S              6S 0 INZ(0)

      *

     D LST1            DS                  OCCURS(9999)

     D  PRDID                        10A

     D  PRDNME                       20A

     D  PRDAMT                       10P 2

      *

     D LST2            DS                  DIM(9999) QUALIFIED

     D  PRDID                        10A

     D  PRDNME                       20A

     D  PRDAMT                       10P 2

      *

      * JSMX_BEGIN

      *

     C                   CALLB(D)  'JSMX_BEGIN'

     C                   PARM                    *OMIT

     C                   PARM                    ZEROLENGTH

      *

      * JSMX_OPEN

      *

     C                   CLEAR                   JSMSRV

     C                   EVAL      JSMSRV = 'LOCALHOST:4560'

     C                   CALLB(D)  'JSMX_OPEN'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMSRV

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * SERVICE_LOAD

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SERVICE_LOAD' +

     C                                      ' SERVICE(ExcelService)' +

     C                                      ' TRACE(*YES)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * CREATE

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'CREATE'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * ADD OBJECT(*SHEET)

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'ADD OBJECT(*SHEET)' +

     C                                      ' SHEET(MyTest)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * ADD OBJECT(*CELLSTYLE)

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'ADD OBJECT(*CELLSTYLE)' +

     C                                      ' TYPE(*NUMBER)' +

     C                                      ' COLUMN(5) RANGE(10,20)' +

     C                                      ' FONT(*TAHOMA)' +

     C                                      ' FORMAT(*FORMAT4)' +

     C                                      ' HALIGN(*RIGHT)' +

     C                                      ' BACKGROUND(*YELLOW)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * WRITE LIST

      *

     C                   EVAL      COUNT = 0

     C     1             DO        9999

     C                   ADD       1             COUNT

     C     COUNT         OCCUR     LST1

     C                   EVAL      PRDID  = 'ID' + %CHAR(COUNT)

     C                   EVAL      PRDNME = 'Product ' + %CHAR(COUNT)

     C                   EVAL      PRDAMT = 1000.45 + COUNT

     C                   ENDDO

      *

     C                   EVAL      ListDefSize  = %SIZE(ListDef1:*ALL)

     C                   EVAL      ListEntSize  = %SIZE(LST1)

     C                   EVAL      ListCount    = COUNT

     C                   EVAL      ListMaxCount = %ELEM(LST1)

     C                   CALLB(D)  'JSMX_BINDLST'

     C                   PARM                    JSMHDL

     C                   PARM                    ListDef1

     C                   PARM                    ListDefSize

     C                   PARM                    LST1

     C                   PARM                    ListEntSize

     C                   PARM                    ListCount

     C                   PARM                    ListMaxCount

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * WRITE R1C1

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'WRITE R1C1(10,3)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * WRITE LIST 2

      *

     C                   EVAL      COUNT = 0

     C     1             DO        9999

     C                   ADD       1             COUNT

     C                   EVAL      LST2(COUNT).PRDID  = 'ID' + %CHAR(COUNT)

     C                   EVAL      LST2(COUNT).PRDNME = 'NME' + %CHAR(COUNT)

     C                   EVAL      LST2(COUNT).PRDAMT = 2000.47 + COUNT

     C                   ENDDO

      *

     C                   EVAL      ListDefSize  = %SIZE(ListDef1:*ALL)

     C                   EVAL      ListEntSize  = %SIZE(LST2)

     C                   EVAL      ListCount    = COUNT

     C                   EVAL      ListMaxCount = %ELEM(LST2)

     C                   CALLB(D)  'JSMX_BINDLST'

     C                   PARM                    JSMHDL

     C                   PARM                    ListDef1

     C                   PARM                    ListDefSize

     C                   PARM                    LST2

     C                   PARM                    ListEntSize

     C                   PARM                    ListCount

     C                   PARM                    ListMaxCount

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * WRITE R1C1

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'WRITE R1C1(10,10)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * SAVE FILE

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SAVE' +

     C                                      ' FILE(demo.xlsx)'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * CLOSE

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'CLOSE'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * SERVICE_UNLOAD

      *

     C                   CLEAR                   JSMCMD

     C                   EVAL      JSMCMD = 'SERVICE_UNLOAD'

     C                   CALLB(D)  'JSMX_COMMAND'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMCMD

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * JSMX_CLOSE

      *

     C                   CALLB(D)  'JSMX_CLOSE'

     C                   PARM                    JSMHDL

     C                   PARM                    JSMSTS

     C                   PARM                    JSMMSG

      *

      * JSMX_END

      *

     C                   CALLB(D)  'JSMX_END'

      *

     C                   SETON                                        LR

 

**CTDATA ListDef1

PRDID                                             A000001000

PRDNME                                            A000002000

PRDAMT                                            P000001002