zoukankan      html  css  js  c++  java
  • ABAP操作Excel(转)

    REPORT YGL_MYOLE.
    INCLUDE OLE2INCL.
    * OLE OBJECT
    DATA:
        MYEXCEL           TYPE OLE2_OBJECT,
        MYSHEET           TYPE OLE2_OBJECT,
        MYCELL             TYPE OLE2_OBJECT,
        MYWORKBOOK  TYPE OLE2_OBJECT.
    .................................
    *创建excel进程
    CREATE OBJECT MYEXCEL 'EXCEL.APPLICATION'.
    * 创建工作表
    CALL METHOD OF MYEXCEL 'WORKBOOKS' = MYWORKBOOK.
    * 创建sheet并添加到工作表
    SET PROPERTY OF MYEXCEL 'SHEETSINNEWWORKBOOK' = 1.
    CALL METHOD OF MYWORKBOOK 'ADD'.
    * 选中excel中的cell,第一行的第二列。
    CALL METHOD OF MYEXCEL 'CELLS' = MYCELL EXPORTING #1 = 1 #2 = 2.
    * 设置被选中的cell的值
    SET PROTERTY OF MYCELL 'VALUE' = 'HELLO WORD'. "你要输出的内容
    GET PROPERTY OF MYEXCEL 'ACTIVESHEET' = MYSHEET.
    GET PROPERTY OF MYEXCEL 'ACTIVEWORKBOOK' = MYWORKBOOK.
    * 保存文件
    CALL METHOD OF MYWORKBOOK 'SAVEAS' EXPORTING #1 = 'C:\TMP\AA.XLS' #2 = 1.
    CALL METHOD OF MYWORKBOOK 'CLOSE'.
    * 推出excel
    CALL METHOD OF MYEXCEL 'QUIT'.
    * 释放对象
    FREE OBJECT MYSHEET.
    FREE OBJECT MYWORKBOOK.
    FREE OBJECT MYEXCEL.

    转(http://www.itpub.net/redirect.php?tid=925318&goto=lastpost
  • 相关阅读:
    epoll
    Neighbor Discovery Protocol Address Resolution Protocol
    text files and binary files
    cron_action
    Automation Scripts
    Toeplitz matrix
    Stolz–Cesàro theorem
    stochastic matrix
    HTTP headers with the Link header field HTTP协议支持分页(Pagination)操作,在Header中使用 Link 即可
    Markov Process
  • 原文地址:https://www.cnblogs.com/byfhd/p/1051771.html
Copyright © 2011-2022 走看看