Quantcast
Channel: SCN : Popular Discussions - ABAP和Java开发 (ABAP & Java Development)
Viewing all articles
Browse latest Browse all 4604

内表导出到excel问题

$
0
0

hello everyone

 

我在程序中用 CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'  将内表内容导出到内表中,但用户用的office2007,

在打开的时候会提示 u2018.XLS::文件格式无效u2019  的错误, 找不到合适的解决方式,

 

请高手们指点 。

 

等 。

谢谢。

 

相关代码如下

 

  CALL METHOD cl_gui_frontend_services=>file_save_dialog

        EXPORTING

  •         WINDOW_TITLE         =

         default_extension    = 'XLS'

  •         DEFAULT_FILE_NAME    =

  •         WITH_ENCODING        =

          file_filter          = 'Excel文件(.XLS)|.XLS|全部文件 (.)|.|'"'*.XLS'

          initial_directory    = 'C:\'

  •         PROMPT_ON_OVERWRITE  = \'X\'

        CHANGING

          filename             = p_filename

          path                 = p_path

          fullpath             = p_fullpath  "路径加文件名称

          user_action          = user_action

  •         FILE_ENCODING        =

        EXCEPTIONS

          cntl_error           = 1

          error_no_gui         = 2

          not_supported_by_gui = 3

          OTHERS               = 4

              .

      IF sy-subrc <> 0.

        MESSAGE '调用file_save_dialog方法出错' TYPE 'I'.

        EXIT.

      ENDIF.

 

 

  DATA:txt_msg TYPE string.

  DATA l_filename TYPE rlgrap-filename.

 

  l_filename = p_fullpath.

 

  CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'

    EXPORTING

  •     I_FIELD_SEPERATOR          =

  •     I_LINE_HEADER              =

      i_filename                 = l_filename

  •     I_APPL_KEEP                = ' '

    TABLES

      i_tab_sap_data             = it_excel

  •   CHANGING

  •     I_TAB_CONVERTED_DATA       =

   EXCEPTIONS

     conversion_failed          = 1

     OTHERS                     = 2

            .

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ELSE.

    CONCATENATE '已生成文件至' l_filename INTO txt_msg.

    MESSAGE txt_msg TYPE 'S'.

  ENDIF.


Viewing all articles
Browse latest Browse all 4604

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>