DATA: IT_FIELD LIKE ZST_EXP_EXCEL_FILE_COND OCCURS 0 WITH HEADER LINE.
CLEAR:IT_FIELD[],IT_FIELD.
...
IT_FIELD-NAME = 'MATNR'.
IT_FIELD-TEXT = '商品编码'.
IT_FIELD-LEN = 10
IT_FIELD-BG_ROW = 1
IT_FIELD-ED_ROW = 1.
IT_FIELD-BG_COLNAME = 'A'
IT_FIELD-ED_COLNAME = 'A'
IT_FIELD-ALIGHT = 'C'. (L,C,R)
APPENDIT_FIELD.
...
"调用函数另存文件
CALL FUNCTION 'ZF_EXP_EXCEL_FILE'
EXPORTING
TITLE = '报表名称'
BORDER = 'X'
ADD_TOTAL_ROW = 'X'
TABLES
IT_TAB_FIELD = IT_FIELD
IT_DATA = IT_DATA.
FUNCTION ZF_EXP_EXCEL_FILE.
*"----------------------------------------------------------------------
*"*"Local inte易做图ce:
*" IMPORTING
*" REFERENCE(TITLE) TYPE CHAR256 OPTIONAL "表头描述
*" REFERENCE(BORDER) TYPE CHAR1 OPTIONAL "边框('空':无边框,否有边框)(可选)
*" REFERENCE(SPECIFY_FORMAT) TYPE CHAR1 OPTIONAL "指定格式('X'按格式导出)(可选)
*" REFERENCE(QUICK_FORMAT) TYPE CHAR1 OPTIONAL "快速保存('X'快速导出)(可选)
*" REFERENCE(ADD_TOTAL_ROW) TYPE CHAR1 OPTIONAL "导出时自动加上合计('X'自动加上)(可选)
*" TABLES
*" IT_COND STRUCTURE ZST_EXP_EXCEL_FILE_COND OPTIONAL "查询条件信息(可选)
*" IT_TAB_FIELD STRUCTURE ZST_EXP_EXCEL_TAB_FD_TITLE OPTIONAL "导出内表的字段描述(可选)
*" IT_FOOTER STRUCTURE ZST_EXP_EXCEL_FILE_COND OPTIONAL "表脚信息(可选)
*" IT_DATA "要被导出的任何数据内表(必填)
*"----------------------------------------------------------------------
DATA:FRM_SELECTLIST LIKE SPOPLI OCCURS 5 WITH HEADER LINE.
DATA:FRM_ANTWORT TYPE C.
DATA:FRM_SELECT_MOD.
CLEAR FRM_SELECT_MOD.
IF IT_DATA[] IS INITIAL.
MESSAGE S001(00) WITH '没有要导出的数据'.
RETURN.
ENDIF.
IF IT_TAB_FIELD[] IS NOT INITIAL.
FRM_SELECT_MOD = 'X'.
ENDIF.
IF SPECIFY_FORMAT IS NOT INITIAL. "指定格式导出
PERFORM FRM_DC_EXCEL TABLES IT_COND IT_TAB_FIELD IT_FOOTER IT_DATA
USING TITLE BORDER ADD_TOTAL_ROW.
RETURN.
ENDIF.
IF QUICK_FORMAT IS NOT INITIAL. "快速格式导出
PERFORM FRM_KSDC_EXCEL TABLES IT_COND IT_TAB_FIELD IT_FOOTER IT_DATA
USING TITLE ADD_TOTAL_ROW.
RETURN.
ENDIF.
IF FRM_SELECT_MOD IS NOT INITIAL.
CLEAR:FRM_SELECTLIST[],FRM_SELECTLIST.
FRM_SELECTLIST-VAROPTION = '按指定格式导出'.
FRM_SELECTLIST-SELFLAG = 'X'. APPEND FRM_SELECTLIST.
CLEAR FRM_SELECTLIST.
FRM_SELECTLIST-VAROPTION = '快速导出'. APPEND FRM_SELECTLIST.
CALL FUNCTION 'POPUP_TO_DECIDE_LIST'
EXPORTING
MARK_MAX = 1
START_COL = 15
START_ROW = 3
TEXTLINE1 = '文件的格式:'
TITEL = '选择导出'
IMPORTING
ANSWER = FRM_ANTWORT
TABLES
T_SPOPLI = FRM_SELECTLIST
EXCEPTIONS
NOT_ENOUGH_ANSWERS = 1
TOO_MUCH_ANSWERS = 2
TOO_MUCH_MARKS = 3
OTHERS = 4.
CASE FRM_ANTWORT.
WHEN '1'.
PERFORM FRM_DC_EXCEL TABLES IT_COND IT_TAB_FIELD IT_FOOTER IT_DATA
USING TITLE BORDER ADD_TOTAL_ROW.
WHEN '2'.
PERFORM FRM_KSDC_EXCEL TABLES IT_COND IT_TAB_FIELD IT_FOOTER IT_DATA
USING TITLE ADD_TOTAL_ROW.
ENDCASE.
ELSE.
PERFORM FRM_KSDC_EXCEL TABLES IT_COND IT_TAB_FIELD IT_FOOTER IT_DATA
USING TITLE ADD_TOTAL_ROW.
ENDIF.
ENDFUNCTION.
"***********将以下代码写入函数INCLUDE的TOP里面***********************
FUNCTION-POOL ZFG_EXP_FILE. "MESSAGE-ID ..
* EXCEL 输出准备
DATA: EXCEL_TITLE(5) VALUE 'TITLE',
EXCEL_COND(5) VALUE 'COND',
EXCEL_TBTIL(5) VALUE 'TBTIL',
EXCEL_TDATA(5) VALUE 'TDATA',
EXCEL_FOOT(5) VALUE 'FOOT'.
DATA: EXCEL_TB_CELL_TITLE_FONT_BOLD TYPE I VALUE 1.
DATA: BEGIN OF IT_EXCEL_ROWS OCCURS 0,
ROWTYP(5), "取值:TITLE,COND,TBTIL,TDATA,FOOT
BG_ROWID TYPE I,