zoukankan      html  css  js  c++  java
  • 进阶-案例九: WD中实现export 到Excel,Doc,Txt.

    1、导出excel 文件代码

    导出事件代码:

    METHOD onactionimport .
    *导出excel:  
      DATA: lo_node TYPE REF TO if_wd_context_node,
            lo_elem TYPE REF TO if_wd_context_element,
            ls_context TYPE wd_this->element_flight,
            lt_context TYPE wd_this->elements_flight,
            lw_string TYPE string,
            lw_xstring TYPE xstring.
    * get the table's context
      lo_node = wd_context->get_child_node( name = 'FLIGHT' ).
      lo_node->get_static_attributes_table( IMPORTING table = lt_context ).
    * create the String(Line)
      LOOP AT lt_context INTO ls_context.
        CONCATENATE lw_string ls_context-carrid
        ls_context-connid
    *    ls_context-text
        cl_abap_char_utilities=>newline INTO
        lw_string SEPARATED BY cl_abap_char_utilities=>horizontal_tab.
      ENDLOOP.
    * convert the string => Xstring
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text     = lw_string
    *     MIMETYPE = ' '
    *     ENCODING =
        IMPORTING
    
          buffer   = lw_xstring
        EXCEPTIONS
          failed   = 1
          OTHERS   = 2.
    * export the XString to Excel
      wdr_task=>client_window->client->attach_file_to_response(
    **path to the word file
    i_filename = 'WDP.xls'
    ** String Variable
      i_content = lw_xstring
    * File Type
    i_mime_type = 'EXCEL' ).
    ENDMETHOD.

     2、若是导出word的话改下参数

    * export the XString to Excel
      wdr_task=>client_window->client->attach_file_to_response(
    **path to the word file
    i_filename = 'WDP.doc'"
    ** String Variable
      i_content = lw_xstring
    * File Type
    i_mime_type = 'word').

    3、若是导出text的话改下参数

    * export the XString to Excel
      wdr_task=>client_window->client->attach_file_to_response(
    **path to the word file
    i_filename = 'WDP.txt'
    ** String Variable
      i_content = lw_xstring
    * File Type
    i_mime_type = 'NOTEPAD').

    同样的道理,利用client_window可以实现输出成XML等.

  • 相关阅读:
    Linux Mint---shutter截图软件
    Linux Mint---fcitx中文,日语输入法
    Linux Mint---安装docky
    Linux Mint---开启桌面三维特效
    Linux Mint---ATI显卡驱动安装篇
    Linux Mint---更新软件源
    Spring Cloud 微服务服务间调用session共享问题
    Jooq批量插入 batch
    idea安装SonarLint语法检测插件
    JVM到底是什么?
  • 原文地址:https://www.cnblogs.com/caizjian/p/4362745.html
Copyright © 2011-2022 走看看