ABAP ZCL_EXCEL 实际用的案例
FORM GETITEMSANDOUTPUT USING PGS_HEAD TYPE GSHEAD.
DATA:FILENAME TYPE STRING.
DATA:LKUNNR TYPE KNA1-KUNNR.
DATA:PROW TYPE I.
DATA:LSDATE TYPE STRING.
DATA:SUMXSJE TYPE DMBTR,
ZYMYE TYPE DMBTR, "月末余额
SUMBYXSYE TYPE DMBTR, "截止本月末销售金额
SUMBYBYYE TYPE DMBTR, "截止本月末备用余额
SUMBYHKHJ TYPE DMBTR, "截止本月末回款余额
SUMF TYPE DMBTR,
SUMJ TYPE DMBTR,
SUMK TYPE DMBTR. "截止本月末回款余额
DATA:LSXSJE TYPE DMBTR.
DATA:LSOTXT TYPE STRING.
DATA: NAME LIKE THEAD-TDNAME,
TLINE TYPE TABLE OF TLINE WITH HEADER LINE.
DATA: LS_LINES(10),"行数
LS_TABIX(10),"循环标号
LS_PECNT TYPE P LENGTH 6 DECIMALS 2, "百分比
LS_PECET(6),"百分数
LS_TEXT(40)."消息
LKUNNR = PGS_HEAD-KUNNR .
SHIFT LKUNNR LEFT DELETING LEADING '0'.
FILENAME = LKUNNR && PGS_HEAD-NAME1 && '.xlsx'.
IF POUTPATH IS INITIAL.
POUTPATH = LV_WORKDIR.
ENDIF.
CL_GUI_FRONTEND_SERVICES=>GET_FILE_SEPARATOR( CHANGING FILE_SEPARATOR = LV_FILE_SEPARATOR ).
CONCATENATE POUTPATH LV_FILE_SEPARATOR FILENAME INTO LV_FULL_PATH.
CREATE OBJECT LO_EXCEL.
" Get active sheet
LO_WORKSHEET = LO_EXCEL->GET_ACTIVE_WORKSHEET( ).
LO_WORKSHEET->SET_TITLE( 'sheet1' ).
CREATE OBJECT LO_BORDER_DARK.
LO_BORDER_DARK->BORDER_COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_BORDER_DARK->BORDER_STYLE = ZCL_EXCEL_STYLE_BORDER=>C_BORDER_THIN.
* 抬头剧中
LO_STYLE_BOLD_BORDER = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER->FONT->BOLD = ABAP_TRUE.
LO_STYLE_BOLD_BORDER->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_CENTER.
LO_STYLE_BOLD_BORDER->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID = LO_STYLE_BOLD_BORDER->GET_GUID( ).
* 末尾左右边框的
LO_STYLE_BOLD_BORDER_LR = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_LR->FONT->BOLD = ABAP_TRUE.
LO_STYLE_BOLD_BORDER_LR->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_LR->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_LR->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_LEFT.
LO_STYLE_BOLD_BORDER_LR->BORDERS->LEFT = LO_BORDER_DARK.
LO_STYLE_BOLD_BORDER_LR->BORDERS->RIGHT = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_LR = LO_STYLE_BOLD_BORDER_LR->GET_GUID( ).
*字体分布
LO_STYLE_BOLD_BORDER_LEFT = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_LEFT->FONT->BOLD = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_LEFT->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_LEFT->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_LEFT->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_JUSTIFY.
LO_STYLE_BOLD_BORDER_LEFT->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_LT = LO_STYLE_BOLD_BORDER_LEFT->GET_GUID( ).
*字体靠左
LO_STYLE_BOLD_BORDER_LEE = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_LEE->FONT->BOLD = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_LEE->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_LEE->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_LEE->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_LEFT.
LO_STYLE_BOLD_BORDER_LEE->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_LE = LO_STYLE_BOLD_BORDER_LEE->GET_GUID( ).
*字体靠右
LO_STYLE_BOLD_BORDER_RIGHT = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_RIGHT->FONT->BOLD = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_RIGHT->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_RIGHT->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_RIGHT->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_RIGHT.
LO_STYLE_BOLD_BORDER_RIGHT->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_RT = LO_STYLE_BOLD_BORDER_RIGHT->GET_GUID( ).
LO_STYLE_BOLD_BORDER_CURR = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_CURR->FONT->BOLD = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_CURR->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_CURR->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_CURR->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_RIGHT.
LO_STYLE_BOLD_BORDER_CURR->NUMBER_FORMAT->FORMAT_CODE = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_XLSX39.
LO_STYLE_BOLD_BORDER_CURR->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_CURR = LO_STYLE_BOLD_BORDER_CURR->GET_GUID( ).
LO_STY_CURR_R = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STY_CURR_R->FONT->BOLD = ABAP_FALSE.
LO_STY_CURR_R->FONT->ITALIC = ABAP_FALSE.
LO_STY_CURR_R->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_RED.
LO_STY_CURR_R->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_RIGHT.
LO_STY_CURR_R->NUMBER_FORMAT->FORMAT_CODE = ZCL_EXCEL_STYLE_NUMBER_FORMAT=>C_FORMAT_XLSX39.
LO_STY_CURR_R->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STY_GUID_CURR_R = LO_STY_CURR_R->GET_GUID( ).
LO_STY_MENGE = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STY_MENGE->FONT->ITALIC = ABAP_FALSE.
LO_STY_MENGE->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STY_MENGE->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_CENTER.
LO_STY_MENGE->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STY_GUID_MENGE = LO_STY_MENGE->GET_GUID( ).
LO_STY_MENGE_R = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STY_MENGE_R->FONT->ITALIC = ABAP_FALSE.
LO_STY_MENGE_R->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_RED.
LO_STY_MENGE_R->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_CENTER.
LO_STY_MENGE_R->BORDERS->ALLBORDERS = LO_BORDER_DARK.
LV_STY_GUID_MENGE_R = LO_STY_MENGE_R->GET_GUID( ).
LO_STYLE_BOLD_BORDER_NT = LO_EXCEL->ADD_NEW_STYLE( ).
LO_STYLE_BOLD_BORDER_NT->FONT->BOLD = ABAP_TRUE.
LO_STYLE_BOLD_BORDER_NT->FONT->ITALIC = ABAP_FALSE.
LO_STYLE_BOLD_BORDER_NT->FONT->COLOR-RGB = ZCL_EXCEL_STYLE_COLOR=>C_BLACK.
LO_STYLE_BOLD_BORDER_NT->ALIGNMENT->HORIZONTAL = ZCL_EXCEL_STYLE_ALIGNMENT=>C_HORIZONTAL_LEFT.
LO_STYLE_BOLD_BORDER_NT->BORDERS->LEFT = LO_BORDER_DARK.
LO_STYLE_BOLD_BORDER_NT->BORDERS->RIGHT = LO_BORDER_DARK.
LO_STYLE_BOLD_BORDER_NT->BORDERS->DOWN = LO_BORDER_DARK.
LV_STYLE_BOLD_BORDER_GUID_NT = LO_STYLE_BOLD_BORDER_NT->GET_GUID( ).
"$. Region 列宽设置
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'A' IP_WIDTH_FIX = '12').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'B' IP_WIDTH_FIX = '20').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'C' IP_WIDTH_FIX = '50').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'D' IP_WIDTH_FIX = '8').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'E' IP_WIDTH_FIX = '12').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'F' IP_WIDTH_FIX = '12').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'G' IP_WIDTH_FIX = '16').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'H' IP_WIDTH_FIX = '12').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'I' IP_WIDTH_FIX = '50').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'J' IP_WIDTH_FIX = '12').
LO_WORKSHEET->SET_COLUMN_WIDTH( IP_COLUMN = 'K' IP_WIDTH_FIX = '12').
"$. Endregion 列宽设置
"$. Region 第一行
LO_WORKSHEET->SET_MERGE( IP_ROW = 1 IP_COLUMN_START = 'A' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 1 IP_COLUMN = 'A' IP_VALUE = '杰克对账单' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
"$. Endregion 第一行
"$. Region 第二行
LO_WORKSHEET->SET_CELL( IP_ROW = 2 IP_COLUMN = 'A' IP_VALUE = '客户号' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 2 IP_COLUMN = 'B' IP_VALUE = LKUNNR IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 2 IP_COLUMN = 'C' IP_VALUE = '客户名称' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_MERGE( IP_ROW = 2 IP_COLUMN_START = 'D' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 2 IP_COLUMN = 'D' IP_VALUE = PGS_HEAD-NAME1 IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
"$. Endregion 第二行
"$. Region 第三行
LO_WORKSHEET->SET_MERGE( IP_ROW = 3 IP_COLUMN_START = 'A' IP_COLUMN_END = 'K' ).
LO_WORKSHEET->SET_CELL( IP_ROW = 3 IP_COLUMN = 'A' IP_VALUE = PGS_HEAD-TITLE IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
"$. Endregion 第三行
"$. Region 第四行
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'A' IP_VALUE = '日期' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'B' IP_VALUE = '物料代码' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'C' IP_VALUE = '型号' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'D' IP_VALUE = '数量' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'E' IP_VALUE = '单价' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'F' IP_VALUE = '销售金额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'G' IP_VALUE = '款项类型' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'H' IP_VALUE = '交货单' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'I' IP_VALUE = '备注文本' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'J' IP_VALUE = '收款金额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = 4 IP_COLUMN = 'K' IP_VALUE = '上期余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
"$. Endregion 第四行
PROW = 4.
CLEAR ZYMYE.
"$. Region 第五 六行 上期金额
PROW = PROW + 1.
CLEAR SUMBYHKHJ.
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '上期销售余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMXSJE = GTHEAD-ZXSQC + GTHEAD-ZXSQCY.
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'H' IP_COLUMN_END = 'J' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
IF SUMXSJE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = SUMXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = SUMXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
SUMK = SUMK + SUMXSJE.
PROW = PROW + 1.
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '上期备用余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'H' IP_COLUMN_END = 'J' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMXSJE = GTHEAD-ZLJQC + GTHEAD-ZXSQCY.
IF SUMXSJE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = SUMXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = SUMXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
SUMK = SUMK + SUMXSJE.
PROW = PROW + 1.
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '上期回款余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'H' IP_COLUMN_END = 'J' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
* LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = GTHEAD-ZSUMHK IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_RT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_DECFLOAT16 ).
IF GTHEAD-ZSUMHK >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = GTHEAD-ZSUMHK IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = GTHEAD-ZSUMHK IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
SUMK = SUMK + GTHEAD-ZSUMHK.
SUMBYHKHJ = GTHEAD-ZSUMHK.
"$. Endregion 第五 六行 上期金额
"$. Region 回款部分
CLEAR SUMBYHKHJ.
LOOP AT GTSK INTO DATA(GSSK) WHERE KUNNR = GTHEAD-KUNNR.
IF GSSK-ZSKDT IN S_BUDAT.
PROW = PROW + 1.
GTITEM-INCLUDE-DATSTR = GSSK-ZSKDT+0(4) && '.' && GSSK-ZSKDT+4(2) && '.' && GSSK-ZSKDT+6(2).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = GTITEM-INCLUDE-DATSTR IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'B' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '回款' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'H' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
IF GSSK-DMBTR >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = GSSK-DMBTR IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = GSSK-DMBTR IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
SUMJ = SUMJ + GSSK-DMBTR.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_VALUE = '' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYHKHJ = SUMBYHKHJ + GSSK-DMBTR.
ENDIF.
ENDLOOP.
"$. Endregion 回款部分
* "$. Region 本月发生额
SELECT LIKP~WADAT_IST,LIPS~MATNR,MAKT~MAKTX, LIPS~LFIMG,LIPS~VBELN,LIPS~VGBEL,VBAP~POSNR,LIPS~LGORT,VBAK~AUART,VBAK~KNUMV,PRCD_ELEMENTS~KBETR
FROM LIPS
JOIN LIKP ON LIPS~VBELN = LIKP~VBELN
JOIN VBAP ON LIPS~VGBEL = VBAP~VBELN AND VBAP~POSNR = LIPS~VGPOS
JOIN VBAK ON VBAK~VBELN = VBAP~VBELN
JOIN MAKT ON LIPS~MATNR = MAKT~MATNR AND MAKT~SPRAS = @SY-LANGU
LEFT JOIN PRCD_ELEMENTS ON PRCD_ELEMENTS~KNUMV = VBAK~KNUMV AND PRCD_ELEMENTS~KPOSN = VBAP~POSNR
AND PRCD_ELEMENTS~KSCHL = 'ZPR3'
WHERE LIKP~KUNNR = @GTHEAD-KUNNR AND LIKP~WADAT_IST IN @S_BUDAT AND LIPS~LGORT IN @S_LGORT AND
LIPS~WERKS IN @S_WERKS AND LIPS~WERKS IN ( SELECT WERKS FROM T001W
JOIN T001K ON T001K~BWKEY = T001W~BWKEY
WHERE BUKRS IN @S_BUKRS )
INTO TABLE @DATA(ZDNINFO).
CLEAR SUMXSJE.
DESCRIBE TABLE ZDNINFO LINES LS_LINES."获取内表行数
SORT ZDNINFO BY LGORT WADAT_IST."排序
LOOP AT ZDNINFO INTO DATA(SDNINFO).
PROW = PROW + 1.
LS_TABIX = SY-TABIX."当前处理的行号
LS_PECNT = LS_TABIX / LS_LINES * 100."已处理百分比
LS_PECET = LS_PECNT.
CONCATENATE '客户' LKUNNR '回款部分正在处理,已完成' LS_PECET '%,共' LS_TABIX '条/' LS_LINES '条' INTO LL_TEXT.
CONDENSE LL_TEXT."整理格式,去掉多余空格,格式更整齐
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR' "调用进度条函数,传入百分比和消息
EXPORTING
PERCENTAGE = LL_PECNT
TEXT = LL_TEXT.
LSDATE = SDNINFO-WADAT_IST+0(4) && '.' && SDNINFO-WADAT_IST+4(2) && '.' && SDNINFO-WADAT_IST+6(2).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = LSDATE IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SHIFT SDNINFO-MATNR LEFT DELETING LEADING '0'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'B' IP_VALUE = SDNINFO-MATNR IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'C' IP_VALUE = SDNINFO-MAKTX IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
IF SDNINFO-AUART = 'ZRJ'."退货用负数
SDNINFO-LFIMG = -1 * SDNINFO-LFIMG.
ENDIF.
IF SDNINFO-LFIMG >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'D' IP_VALUE = SDNINFO-LFIMG IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_MENGE ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'D' IP_VALUE = SDNINFO-LFIMG IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_MENGE_R ).
ENDIF.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'E' IP_VALUE = SDNINFO-KBETR IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
LSXSJE = SDNINFO-KBETR * SDNINFO-LFIMG.
SUMXSJE = SUMXSJE + LSXSJE.
IF LSXSJE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'F' IP_VALUE = LSXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'F' IP_VALUE = LSXSJE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
SUMF = SUMF + LSXSJE.
CASE SDNINFO-LGORT.
WHEN '4101'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '销售' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYXSYE = SUMBYXSYE + LSXSJE.
WHEN '4103'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '返修' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYXSYE = SUMBYXSYE + LSXSJE.
WHEN '4202'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '电控部备用' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYBYYE = SUMBYBYYE + LSXSJE.
WHEN '4206'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'G' IP_VALUE = '零件部备用' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYBYYE = SUMBYBYYE + LSXSJE.
ENDCASE.
SHIFT SDNINFO-VBELN LEFT DELETING LEADING '0'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'H' IP_VALUE = SDNINFO-VBELN IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
NAME = SDNINFO-VGBEL.
CALL FUNCTION 'READ_TEXT'
EXPORTING
ID = '0001'
LANGUAGE = '1'
NAME = NAME
OBJECT = 'VBBK'
TABLES
LINES = TLINE
EXCEPTIONS
ID = 1
LANGUAGE = 2
NAME = 3
NOT_FOUND = 4
OBJECT = 5
REFERENCE_CHECK = 6
WRONG_ACCESS_TO_ARCHIVE = 7
OTHERS = 8.
CLEAR LSOTXT.
LOOP AT TLINE.
CONCATENATE LSOTXT TLINE-TDLINE INTO LSOTXT.
ENDLOOP.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'I' IP_VALUE = LSOTXT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
ENDLOOP.
"$. Endregion 本月发生额
DATA:PREPROW TYPE I .
DATA:LV_CELL_VALUE TYPE STRING.
PREPROW = PROW.
* 汇总行
PROW = PROW + 1.
LSOTXT = 'SUM(F4:F' && PREPROW && ')'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '汇总' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'B' IP_COLUMN_END = 'E' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
IF SUMF >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'F' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LO_STYLE_BOLD_BORDER_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'F' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
LSOTXT = 'SUM(J4:J' && PREPROW && ')'.
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
IF SUMJ >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LO_STYLE_BOLD_BORDER_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
LSOTXT = 'SUM(K4:K' && PREPROW && ')'.
IF SUMK >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LO_STYLE_BOLD_BORDER_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'K' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
* 月末余额
PREPROW = PROW.
PROW = PROW + 1.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '月末余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'B' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LSOTXT = 'F' && PREPROW && '-J' && PREPROW && '+K' && PREPROW.
IF SUMF - SUMJ + SUMK >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'B' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LO_STYLE_BOLD_BORDER_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'B' IP_FORMULA = LSOTXT IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
* 制表人
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
SELECT SINGLE USREFUS~USERALIAS FROM USREFUS WHERE BNAME = @SY-UNAME INTO @DATA(LALIAS).
LSOTXT = '制表人:' && LALIAS ."' && '(' && SY-UNAME && ')'.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = LSOTXT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = '客户回签(签字/盖章)' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_RT ).
* 电话
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '电话:0576-88159077' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = '传真:0576-88177758' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_RT ).
* 截止本月零件销售余额: 877.97
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '截止本月零件销售余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
* 本月发生 年初 + 历史Delta
SUMBYXSYE = SUMBYXSYE + GTHEAD-ZXSQC + GTHEAD-ZXSQCY.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
IF SUMBYXSYE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYXSYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYXSYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
*截止本月零件备用余额: 6,999.95
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '截止本月零件备用余额' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
SUMBYBYYE = SUMBYBYYE + GTHEAD-ZLJQC + GTHEAD-ZLJQCY.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
IF SUMBYBYYE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYBYYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYBYYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
*截至本月零件回款合计: 3,200.00
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '截至本月零件回款合计' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
IF SUMBYHKHJ >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYHKHJ IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = SUMBYHKHJ IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
*截至本月零件余额合计: 4,677.92
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'F' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '截至本月零件余额合计' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_AREA( IP_ROW = PROW IP_COLUMN_START = 'G' IP_COLUMN_END = 'I' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LT ).
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'J' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID ).
ZYMYE = SUMBYXSYE + SUMBYBYYE - SUMBYHKHJ.
IF ZYMYE >= 0.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = ZYMYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_CURR ).
ELSE.
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'J' IP_VALUE = ZYMYE IP_ABAP_TYPE = CL_ABAP_TYPEDESCR=>TYPEKIND_FLOAT IP_STYLE = LV_STY_GUID_CURR_R ).
ENDIF.
*"温馨提醒:
*一、以上是贵司和我司发生的往来帐明细表,请及时核对确认,如有疑问请于一星期内前将问题书面反馈至我司,我司将及时给予处理,如未回复,视同贵司认可以上余额,谢谢合作。
*二、本司将以此为据确认贵司的实际应收款,负数表示您尚在我司的预付款。
*三、我司对帐时间:次月4-6号。"
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '温馨提醒' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW IP_COLUMN = 'A' IP_VALUE = '一、以上是贵司和我司发生的往来帐明细表如有疑问请于一星期内前将问题书面反馈至我司,我司将及时给予处理,如未回复,视同贵司认可以上余额,请及时核对确认,谢谢合作。' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE( IP_ROW = PROW IP_COLUMN_START = 'A' IP_COLUMN_END = 'K' IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW
IP_COLUMN = 'A'
IP_VALUE = '二、本司将以此为据确认贵司的实际应收款,负数表示您尚在我司的预付款'
IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_LR ).
PROW = PROW + 1.
LO_WORKSHEET->SET_MERGE(
IP_ROW = PROW
IP_COLUMN_START = 'A'
IP_COLUMN_END = 'K'
IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_NT ).
LO_WORKSHEET->SET_CELL( IP_ROW = PROW
IP_COLUMN = 'A'
IP_VALUE = '三、我司对帐时间:次月4-6号。'
IP_STYLE = LV_STYLE_BOLD_BORDER_GUID_NT ).
CREATE OBJECT LO_EXCEL_WRITER TYPE ZCL_EXCEL_WRITER_2007.
LV_FILE = LO_EXCEL_WRITER->WRITE_FILE( LO_EXCEL ).
" Convert to binary
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = LV_FILE
IMPORTING
OUTPUT_LENGTH = LV_BYTECOUNT
TABLES
BINARY_TAB = LT_FILE_TAB.
" Save the file
CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD( EXPORTING BIN_FILESIZE = LV_BYTECOUNT
FILENAME = LV_FULL_PATH
FILETYPE = 'BIN'
CHANGING DATA_TAB = LT_FILE_TAB ).
WRITE:/ '客户' && LKUNNR && '已经写入文件' && LV_FULL_PATH.
ENDFORM.