*----------------------------------------------------------------------*
* INCLUDE Z_EXCEL *
*----------------------------------------------------------------------*
data: w_xl type ole2_object,
w_cl type ole2_object,
w_wkbook type ole2_object,
w_ws type ole2_object.
data: w_success type c.
data: columnsobj type ole2_object, " Columns object
rowsobj type ole2_object, " Range object
bordersobj type ole2_object, " Borders object
entirecolumnobj type ole2_object,
fontobj type ole2_object. " Font object.
*&---------------------------------------------------------------------*
*& Form open_excel
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_FILE text
*----------------------------------------------------------------------*
form open_excel using p_file.
create object w_xl 'Excel.Application'.
if sy-subrc ne 0.
write: / 'Excel init failed, return code is', sy-subrc.
exit.
else.
set property of w_xl 'Visible' = 0.
call method of w_xl 'Workbooks' = w_wkbook.
call method of w_wkbook 'Open' = w_wkbook
exporting #1 = p_file.
call method of w_wkbook 'Worksheets' = w_ws
exporting #1 = 'Sheet1'.
call method of w_ws 'Activate'.
endif.
endform. " open_excel
*&---------------------------------------------------------------------*
*& Form GET_CELL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_W_ROW text
* -->P_2 text
* -->P_I_BASEDATA_ORGEN2 text
*----------------------------------------------------------------------*
form get_cell using p_row
p_column
changing p_record.
call method of w_ws 'cells' = w_cl
exporting #1 = p_row #2 = p_column.
get property of w_cl 'value' = p_record.
endform. " GET_CELL
*&---------------------------------------------------------------------*
*& Form GET_CELL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_W_ROW text
* -->P_2 text
* -->P_I_BASEDATA_ORGEN2 text
*----------------------------------------------------------------------*
form get_cellt using p_row
p_column
changing p_record.
call method of w_ws 'cells' = w_cl
exporting #1 = p_row #2 = p_column.
get property of w_cl 'text' = p_record.
endform. " GET_CELL
*&---------------------------------------------------------------------*
*& Form CLOSE_EXCEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
form close_excel.
call method of w_wkbook 'Save'.
call method of w_wkbook 'Close' exporting #1 = 0.
call method of w_xl 'Quit'.
free object w_cl.
free object w_ws.
free object w_wkbook.
free object w_xl.
endform. " CLOSE_EXCEL
*&---------------------------------------------------------------------*
*& Form SET_CELL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_W_ROW text
* -->P_1 text
* -->P_W_XUHAO text
*----------------------------------------------------------------------*
form set_cell using p_row
p_colum
p_value.
call method of w_ws 'cells' = w_cl exporting #1 = p_row #2 = p_colum.
set property of w_cl 'value' = p_value.
endform. " SET_CELL
*&---------------------------------------------------------------*
*& Form FILL_XLS
*&---------------------------------------------------------------*
* 将数据放入EXCEL的单元格中并设置属性
* -->P_ROW 行
* -->P_COLUMN 列
* -->P_DATUM 数据
*----------------------------------------------------------------*
form fill_xls using value(p_row) value(p_column) value(p_datum)
value(p_color) value(p_size) value(p_bold)
value(is_number).
if is_number = 1
* &n