ITPub博客

首页 > Linux操作系统 > Linux操作系统 > OLE EXCEL 中添加图片,link server示例

OLE EXCEL 中添加图片,link server示例

原创 Linux操作系统 作者:fengleihen 时间:2009-05-25 22:19:23 0 删除 编辑
REPORT  ZFENGLEIHEN_TEST.

TYPE-POOLS: SBDST, ABAP.
INCLUDE OLE2INCL.
DATA: GRAPHIC_URL(255).
DATA: BEGIN OF ITAB  OCCURS 0,
         RAW TYPE SDOK_SDATX,
      END OF ITAB.
* OLE OBJECT
DATA: MYEXCEL    TYPE OLE2_OBJECT,
      MYSHEET    TYPE OLE2_OBJECT,
      MYCELL     TYPE OLE2_OBJECT,
      MYWORKBOOK TYPE OLE2_OBJECT,
      LO_SHEET   TYPE OLE2_OBJECT,
      LO_RANGE1   TYPE OLE2_OBJECT,
      LO_RANGE3   TYPE OLE2_OBJECT,
      LO_RANGE2   TYPE OLE2_OBJECT.

PERFORM. GET_URL.
CREATE OBJECT MYEXCEL 'EXCEL.APPLICATION'.
SET PROPERTY OF MYEXCEL 'DisplayAlerts' = 0.
CALL METHOD OF MYEXCEL 'WORKBOOKS' = MYWORKBOOK.
SET PROPERTY OF MYEXCEL 'VISIBLE' = 1.
SET PROPERTY OF MYEXCEL 'SHEETSINNEWWORKBOOK' = 1.
CALL METHOD OF MYWORKBOOK 'ADD'.


CALL METHOD OF MYEXCEL 'WORKSHEETS' = LO_SHEET
  EXPORTING #1 = 1.
CALL METHOD OF LO_SHEET 'ACTIVATE'.
SET PROPERTY OF LO_SHEET 'NAME' = 'TEXT1'.
*  'THIS IS MY CREATED EXCEL'.

CALL METHOD OF LO_SHEET 'CELLS' = LO_RANGE2
  EXPORTING
  #1 = 7
  #2 = 7.
CALL METHOD OF LO_RANGE2 'SELECT'.
CALL METHOD OF LO_SHEET 'Paste'.

FREE OBJECT LO_SHEET.
*&---------------------------------------------------------------------*
*&      Form.  get_url
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM. GET_URL.


* OAOR 上传图片 并把change Attributes中的KEYWORDS设置成FENGLEIHEN_LOGO
  DATA: SIGNATURE  TYPE SBDST_SIGNATURE   WITH HEADER LINE,
        URIS       TYPE SBDST_URI         WITH HEADER LINE.

  MOVE: '1' TO SIGNATURE-DOC_COUNT,
        '1' TO SIGNATURE-COMP_COUNT.
  MOVE: 'BDS_KEYWORD' TO SIGNATURE-PROP_NAME,
        'FENGLEIHEN_LOGO' TO SIGNATURE-PROP_VALUE.
  APPEND SIGNATURE.
  CALL METHOD CL_BDS_DOCUMENT_SET=>GET_WITH_URL
    EXPORTING
      CLASSNAME    = 'PICTURES'
      CLASSTYPE    = 'OT'
      URL_LIFETIME = 'T'
    CHANGING
      URIS         = URIS[]
      SIGNATURE    = SIGNATURE[].
  READ TABLE URIS INDEX 1 .
  IF SY-SUBRC = 0 .
    GRAPHIC_URL = URIS-URI .
  ENDIF .
  PERFORM. GET_PIC.

ENDFORM.                    "get_url
*&---------------------------------------------------------------------*
*&      Form.  get_pic
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM. GET_PIC.

  DATA: LINK_SERVER TYPE REF TO I_OI_LINK_SERVER,
        CONTROL TYPE REF TO I_OI_CONTAINER_CONTROL,
        RET TYPE SOI_RET_STRING.
  CALL METHOD C_OI_CONTAINER_CONTROL_CREATOR=>GET_CONTAINER_CONTROL
    IMPORTING
      CONTROL = CONTROL
      RETCODE = RET.

  CALL METHOD CONTROL->INIT_CONTROL
    EXPORTING
      R3_APPLICATION_NAME     = 'EXCEL.APPLICATION'
      INPLACE_ENABLED         = ''
      PARENT                  = CL_GUI_CONTAINER=>SCREEN0
      REGISTER_ON_CLOSE_EVENT = 'X'
    IMPORTING
      RETCODE                 = RET.

* Link Server mit Control Verbinden
  CALL METHOD CONTROL->GET_LINK_SERVER
    IMPORTING
      LINK_SERVER = LINK_SERVER
      RETCODE     = RET.

* Link Server starten
  CALL METHOD LINK_SERVER->START_LINK_SERVER
    EXPORTING
      LINK_SERVER_MODE   = LINK_SERVER->LINK_SERVER_CUSTOMNAME
      SERVER_NAME_SUFFIX = 'FENGLEIHEN_SAP_LOGO'
    IMPORTING
      RETCODE            = RET.
  CALL METHOD LINK_SERVER->ADD_BINARY_ITEM
    EXPORTING
      DATA_TYPE    = 'image/gif'
      ITEM_NAME    = 'fengleihen'
      TABLE_URL    =  GRAPHIC_URL
      .
  CALL METHOD LINK_SERVER->COPY_LINK_ITEM_TO_CLIPBOARD
    EXPORTING
      ITEM_NAME = 'fengleihen'
      .
  CALL METHOD LINK_SERVER->REMOVE_LINK_ITEM
    EXPORTING
      ITEM_NAME = 'fengleihen'
    .

ENDFORM.                    "get_pic

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/139677/viewspace-604084/,如需转载,请注明出处,否则将追究法律责任。

上一篇: alv html alv pic
下一篇: 配置sap mail
请登录后发表评论 登录
全部评论

注册时间:2009-03-31

  • 博文量
    24
  • 访问量
    26551