ABAP OLE XLS

news/2024/7/6 1:10:11
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.


------------------------------------------

REPORT Excel.
TABLES:
  sflight.

* header data................................
DATA :
  header1 LIKE gxxlt_p-text VALUE 'Raj',
  header2 LIKE gxxlt_p-text VALUE 'Excel sheet'.

* Internal table for holding the SFLIGHT data
DATA BEGIN OF t_sflight OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA END   OF t_sflight.

* Internal table for holding the horizontal key.
DATA BEGIN OF  t_hkey OCCURS 0.
        INCLUDE STRUCTURE gxxlt_h.
DATA END   OF t_hkey .

* Internal table for holding the vertical key.
DATA BEGIN OF t_vkey OCCURS 0.
        INCLUDE STRUCTURE gxxlt_v.
DATA END   OF t_vkey .

* Internal table for holding the online text....
DATA BEGIN OF t_online OCCURS 0.
        INCLUDE STRUCTURE gxxlt_o.
DATA END   OF t_online.

* Internal table to hold print text.............
DATA BEGIN OF t_print OCCURS 0.
        INCLUDE STRUCTURE gxxlt_p.
DATA END   OF t_print.

* Internal table to hold SEMA data..............
DATA BEGIN OF t_sema OCCURS 0.
        INCLUDE STRUCTURE gxxlt_s.
DATA END   OF t_sema.

* Retreiving data from sflight.
SELECT * FROM sflight
         INTO TABLE t_sflight.
do 10 times.
enddo.
* Text which will be displayed online is declared here....
t_online-line_no    = '1'.
t_online-info_name  = 'Created by'.
t_online-info_value = 'Raj'.
APPEND t_online.

* Text which will be printed out..........................
t_print-hf     = 'H'.
t_print-lcr    = 'L'.
t_print-line_no = '1'.
t_print-text   = 'This is the header'.
APPEND t_print.

t_print-hf     = 'F'.
t_print-lcr    = 'C'.
t_print-line_no = '1'.
t_print-text   = 'This is the footer'.
APPEND t_print.

* Defining the vertical key columns.......
t_vkey-col_no   = '1'.
t_vkey-col_name = 'MANDT'.
APPEND t_vkey.

t_vkey-col_no   = '2'.
t_vkey-col_name = 'CARRID'.
APPEND t_vkey.

t_vkey-col_no   = '3'.
t_vkey-col_name = 'CONNID'.
APPEND t_vkey.

t_vkey-col_no   = '4'.
t_vkey-col_name = 'FLDATE'.
APPEND t_vkey.

* Header text for the data columns................

t_hkey-row_no = '1'.
t_hkey-col_no = 1.
t_hkey-col_name = 'PRICE'.
APPEND t_hkey.

t_hkey-col_no = 2.
t_hkey-col_name = 'CURRENCY'.
APPEND t_hkey.

t_hkey-col_no = 3.
t_hkey-col_name = 'PLANETYPE'.
APPEND t_hkey.

t_hkey-col_no = 4.
t_hkey-col_name = 'SEATSMAX'.
APPEND t_hkey.

t_hkey-col_no = 5.
t_hkey-col_name = 'SEATSOCC'.
APPEND t_hkey.

t_hkey-col_no = 6.
t_hkey-col_name = 'PAYMENTSUM'.
APPEND t_hkey.

* populating the SEMA data..........................
t_sema-col_no  = 1.
t_sema-col_typ = 'STR'.
t_sema-col_ops = 'DFT'.
APPEND t_sema.

t_sema-col_no = 2.
APPEND t_sema.

t_sema-col_no = 3.
APPEND t_sema.

t_sema-col_no = 4.
APPEND t_sema.

t_sema-col_no = 5.
APPEND t_sema.

t_sema-col_no = 6.
APPEND t_sema.

t_sema-col_no = 7.
APPEND t_sema.

t_sema-col_no = 8.
APPEND t_sema.

t_sema-col_no = 9.
APPEND t_sema.

t_sema-col_no = 10.
t_sema-col_typ = 'NUM'.
t_sema-col_ops = 'ADD'.
APPEND t_sema.

CALL FUNCTION 'XXL_FULL_API'
  EXPORTING
*   DATA_ENDING_AT          = 54
*   DATA_STARTING_AT        = 5
   filename                = 'TESTFILE'
   header_1                = header1
   header_2                = header2
   no_dialog               = 'X'
   no_start                = ' '
    n_att_cols              = 6
    n_hrz_keys              = 1
    n_vrt_keys              = 4
   sema_type               = 'X'
*   SO_TITLE                = ' '
  TABLES
    data                    = t_sflight
    hkey                    = t_hkey
    online_text             = t_online
    print_text              = t_print
    sema                    = t_sema
    vkey                    = t_vkey
 EXCEPTIONS
   cancelled_by_user       = 1
   data_too_big            = 2
   dim_mismatch_data       = 3
   dim_mismatch_sema       = 4
   dim_mismatch_vkey       = 5
   error_in_hkey           = 6
   error_in_sema           = 7
   file_open_error         = 8
   file_write_error        = 9
   inv_data_range          = 10
   inv_winsys              = 11
   inv_xxl                 = 12
   OTHERS                  = 13
          .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF. 



http://www.niftyadmin.cn/n/2085182.html

相关文章

CURL的学习和应用

curl安装&#xff1a; xp下面的安装 &#xff1a;修改php.ini文件的设置&#xff0c;找到php_curl.dll //取消下在的注释 extensionphp_curl.dll linux下面安装&#xff1a; # wget http://curl.haxx.se/download/curl-7.17.1.tar.gz # tar zxvf curl-7.17.1.tar.gz //解压 #cd…

推荐软件:Quset PowerGUI

PowerGUI simplifies management via Microsoft Windows PowerShell with an intuitive user console that includes Point, Click, Script™ for quickly building scripts using only a mouse. For more advanced scripting needs, PerfectScript™ provides tools for admin…

camera杂项---两种shutter

什么是快门 快门是照相机用来控制感光片有效曝光时间的机构。是照相机的一个重要组成部分&#xff0c;它的结构、形式及功能是衡量照相机档次的一个重要因素。 什么是Global Shutter&#xff08;Total Shutter&#xff09;&#xff1f; 通过整幅场景在同一时间曝光实现的。Se…

心得笔记--色彩空间

在电子领域&#xff0c;常用的东西都可以量化&#xff0c;比如声音&#xff0c;用一秒钟采样声音的幅值48k或者44.1k次&#xff0c;那这些数值记录下来&#xff0c;可以描述一段时间声音。播放的时候可以用这段数据通过adc模拟出来输送到喇叭或者耳机上来。 我们眼睛所看到的大…

AAA配置实例

测试目的&#xff1a;通过AAA&#xff0c;实现用户级的授权 测试环境&#xff1a;TACACS &#xff0c;1720路由器 测试过程&#xff1a; 实验一&#xff1a;用本地&#xff08;LOCAL&#xff09;方法进行验证和授权 配置文件&#xff1a; version 12.1 ! hostname Router ! aaa…

angular学习(七)-- Service

1.7 服务&#xff1a;Service 如果做过后台开发&#xff0c;那么对 Angular 中的服务就好理解多了。 在 Angular 中&#xff0c;服务的概念和后台的服务概念基本是一样的&#xff0c;差别只是在于技术细节。 服务是对公共代码的抽象&#xff0c;比如&#xff0c;如果在多个控制…

安装和使用Glassfish

安装和使用Glassfish Glassfish是Sun Microsystem支持的一个开源社区&#xff0c;它参考了Apache, Eclipse等开源社区的模式&#xff0c;通过OpenSource实现了Java EE 5的全部功能。 Sun的Java System Application PE 9和Java EE 5 SDK即以Glassfish为基础。更多Glassfish的功能…

camera dhpy和csi2协议分析

简介 MIPI&#xff08;移动行业处理器接口&#xff09;是Mobile Industry Processor Interface的缩写。 MIPI联盟一系列的手机内部接口标准&#xff0c;其中最常用的是&#xff1a; 像头接口CSI&#xff08;CameraSerialInterface&#xff09;定义了一个位于处理器和摄像模组之…