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等.

  • 相关阅读:
    javascript中事件
    pku 1836 Alignment
    pku 3086 Triangular Sums
    [转]asp格式化日期
    用数组作checkboxlist数据源
    (转)Membership、MembershipUser和Roles类 详解
    asp中判断 checkbox 是否选中
    使用 AddRange 方法将多个 ListItem 对象添加到集合
    My97DatePicker,一个兼容所有浏览器的日历选择脚本(相当经典)
    .Net下批量删除数据的存储过程问题(用动态SQL )
  • 原文地址:https://www.cnblogs.com/caizjian/p/4362745.html
Copyright © 2011-2022 走看看