SAP EXCEL 导入,解决WPS无法导入问题


FORM upload_file.
  DATA: l_file       TYPE string,
        rawtab(4096) TYPE c OCCURS 0,
        p_pfilename  TYPE rlgrap-filename,
        ws_ext(3)    TYPE c,
        ws_ext1(4)   TYPE c,
        length1      TYPE i,
        length2      TYPE i,
        length       TYPE i.
 
  DATA: lt_data TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
  DATA: ls_data TYPE alsmex_tabline.
 
  CONDENSE p_pfile.
  length = strlen( p_pfile ).
  IF length < 3.
    MESSAGE '请选择正确的文件!' TYPE 'I'.
    LEAVE LIST-PROCESSING.
 
  ENDIF.
 
 
 
 
  length1 = length - 3.
  ws_ext = p_pfile+length1(3).
  TRANSLATE ws_ext TO UPPER CASE.
  length2 = length - 4.
  ws_ext1 = p_pfile+length2(4).
  TRANSLATE ws_ext1 TO UPPER CASE.
 
 
 
  IF ws_ext = 'XLS' OR ws_ext1 = 'XLSX'.
    p_pfilename = p_pfile.
 
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'    "读取excel文件中的内容
      EXPORTING
        filename    = p_pfilename
        i_begin_col = '1'
        i_begin_row = '1'
        i_end_col   = '50'
        i_end_row   = '5000'
      TABLES
        intern      = lt_data[].
    DELETE lt_data WHERE row EQ 1.
    FIELD-SYMBOLS: .
    LOOP AT lt_data INTO ls_data.
      ASSIGN COMPONENT ls_data-col OF STRUCTURE gs_template TO .
      "动态方法将值传到相应的内表
      = ls_data-value.
 
      AT END OF row.
        APPEND gs_template  TO gt_template.
        CLEAR: gs_template.
      ENDAT.
    ENDLOOP.
 
  ENDIF.
*  ELSEIF WS_EXT = 'TXT'.
*    P_PFILENAME = P_PFILE.
*    CALL FUNCTION 'WS_UPLOAD'
*      EXPORTING
*        FILENAME                = P_PFILENAME
*        FILETYPE                = 'DAT'
*      TABLES
*        DATA_TAB                = GT_TEMPLATE[]
*      EXCEPTIONS
*        CONVERSION_ERROR        = 1
*        FILE_OPEN_ERROR         = 2
*        FILE_READ_ERROR         = 3
*        INVALID_TYPE            = 4
*        NO_BATCH                = 5
*        UNKNOWN_ERROR           = 6
*        INVALID_TABLE_WIDTH     = 7
*        GUI_REFUSE_FILETRANSFER = 8
*        CUSTOMER_ERROR          = 9.
*  ELSE.
*
*    MESSAGE E000(Z99) WITH
*    '文件必需是  XLS OR TXT!' '' '' ''.
*  ENDIF.
 
 
  IF gt_template[] IS INITIAL.
    MESSAGE e000(z99) WITH    '文件是空的!' '' '' ''.
  ENDIF.
  PERFORM frm_check_data."数据检查
  "MOVE-CORRESPONDING GT_HEADLIST1 TO GT_ALV.
ENDFORM.
————————————————
版权声明:本文为CSDN博主「无冬不夏」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/ding15779711955/article/details/127428218

你可能感兴趣的:(excel,wps)