• ABAP ole操作


    1.ole 如何保存和退出
    call method of sheetname 'saves'
    exporting
    #1 = filepath
    #2 = 1.

    call method of applicationname 'quit'.


    2.给sheet 重命名,
    call method of sheetname 'name' = 'sheetname'.

    3.创建application
    call method of XXX 'excel.application'


    4.设置XXX 的显示模式
    set property of XXX 'visible' = 1.  "1显示EXCEL,0不显示EXCEL

    5.创建workbook
    call method of
    excel
    'WORKBOOKS' = WORKBOOK.

    CALL METHOD OF
    WORKBOOK
    'ADD'.


    *&=====================================================================
    1.ole中如何保存和退出。
    -------------------------------------------------------------------------
    call method of sheetname 'saveas'
    exporting
    #1 = filepath
    #2 = 1.

    call method of applicationname 'quit'.


    2.给sheet重命名。
    -------------------------------------------------------------------------
    call method of sheetname 'name' = 'sheetname'.


    3.创建application.
    -------------------------------------------------------------------------
    call method of XXX 'excel.application'.


    4.设置XXX的显示模式。
    -------------------------------------------------------------------------
    set property of XXX 'visible' = 1."前台运行。为0时表示为后台运行。


    5.创建workbook.
    -------------------------------------------------------------------------
    CALL METHOD OF
    EXCEL
    'WORKBOOKS' = WORKBOOK.

    CALL METHOD OF
    WORKBOOK
    'ADD'.


    6.在一个WORKBOOK中添加一个WORKSHEET.
    -------------------------------------------------------------------------
    CALL METHOD OF
    APPLICATIONNAME
    'sheets'
    =WORKSHEET.

    CALL METHOD OF
    WORKSHEET
    'Add'.


    7.给单元格赋值。
    -------------------------------------------------------------------------
    CALL METHOD OF EXCEL 'CELLS' = CELL
    EXPORTING
    #1 = 2
    #2 = 2.
    SET PROPERTY OF CELL 'value'= XXXX.


    8.指定要被操作的SHEET.
    -------------------------------------------------------------------------
    CALL METHOD OF
    APPLICATIONNAME
    'Worksheets'
    =SHEET
    EXPORTING
    #1 = 'sheet3'.

    这里SHEET3为要操作的SHEET的名字。
    CALL METHOD OF SHEET 'Activate '.


    9.指定操作的单元格的范围。
    -------------------------------------------------------------------------
    CALL METHOD OF APPLICATIONNAME 'Range' = RANGE
    EXPORTING
    #1 = 'B2'
    #2 = 'c2'.


    10.如何操作范围内的单元格。/RANGE也为已经定义好的OLE2_OBJECT.
    CALL METHOD OF RANGE 'select '.

    SET PROPERTY OF RANGE 'MergeCells' = 0 . 合并单元格,0时不合并,1则合并。与前面一起使用

    SET PROPERTY OF RANGE 'HorizontalAlignment' = 10 .

    SET PROPERTY OF RANGE 'VerticalAlignment' = -4108 .


    11.单元格内部属性的操作.
    -------------------------------------------------------------------------
    CALL METHOD OF
    CELL
    'INTERIOR' = INT.
    SET PROPERTY OF INT 'ColorIndex' = COLOR. 颜色
    SET PROPERTY OF INT 'Pattern' = PATTERN.

    12.单元格内字体的操作.
    -------------------------------------------------------------------------
    CALL METHOD OF
    CELL
    'FONT' = FONT.
    SET PROPERTY OF FONT 'BOLD' = BOLD.
    SET PROPERTY OF FONT 'SIZE' = SIZE.


    13.边框的操作.
    -------------------------------------------------------------------------
    CALL METHOD OF
    CELL
    'BORDERS' = BORDERS
    EXPORTING
    #1 = '1'.
    1-LEFT 2-RIGHT 3-TOP 4-BOTTOM

    SET PROPERTY OF BORDERS 'Linestyle' = PLINESTYLE .

    SET PROPERTY OF BORDERS 'Weight' = PWEIGHT .

    FREE OBJECT BORDERS. "在此之前应该指定RANGE.


    !!!14.复制与粘贴.
    -------------------------------------------------------------------------
    CALL METHOD OF
    SHEET
    'copy'.

    CALL METHOD OF
    SHEET
    'paste'.

    15.一点注意。
    *在操作SHEET时,默认为上次操作的SHEET.
    *如果想更换,参考8。

    16.一个问题。有时输入数据如111111111111111111,会显示为1E+17。
    -------------------------------------------------------------------------
    解决办法:
    CALL METHOD OF H_EXCEL 'COLUMNS' = COLUMNOBJ
    EXPORTING
    #1 = 6. "the column number

    SET PROPERTY OF COLUMNOBJ 'ColumnWidth' = 10.

    SET PROPERTY OF COLUMNOBJ 'NumberFormat' = '@'.

    17。打开一个WORKBOOK.
    -------------------------------------------------------------------------
    CALL METHOD OF
    WORKBOOK
    'Open'

    EXPORTING
    #1
    =FILENAME+PATH.


    18.所有的操作方法都可以在SELL----表 OLELOAD 中查询到。
    -------------------------------------------------------------------------


    19.执行宏。
    -------------------------------------------------------------------------
    CALL METHOD OF EXCEL 'RUN' EXPORTING #1 ='ZMACRO2'.

    20。清除RANGE 内容
    -------------------------------------------------------------------------
    CALL METHOD OF EXCEL 'Range' = RANGE
    EXPORTING
    #1 = TAR_CELL
    #2 = TAR_CELL.

    CALL METHOD OF
    RANGE
    'ClearContents'.


    21 合并单元格
    -------------------------------------------------------------------------
    CALL METHOD OF EXCEL 'Range' = RANGE
    EXPORTING
    #1 = SOR_CELL
    #2 = TAR_CELL.
    SET PROPERTY OF RANGE 'MergeCells' = 1.


    22.缩小字体填充
    -------------------------------------------------------------------------
    SET PROPERTY OF RANGE 'ShrinkToFit' = 0 .
    "NOTE: 为0时取消缩小字体填充,为1时设置缩小字体填充。

    NOTE:
    1.与OLE相关的关键字存储在表OLELOAD中。
    2.如果有些OLE方法不熟悉,可以利用VBA录制宏来寻找相关的关键字。

  • 相关阅读:
    Flume-概述-安装
    Hive-函数
    Hive_查询
    Hive-DML数据操作
    JDBC-文档
    Hive-DDL数据定义
    Hive-数据类型
    理解RESTful架构
    REST介绍
    [转]详述DHCP服务器的三种IP分配方式
  • 原文地址:https://www.cnblogs.com/rainysblog/p/11289498.html
Copyright © 2020-2023  润新知