* ZEXCLDEF
TYPE-POOLS ole2.
DATA: excel TYPE ole2_object, "Excel object
app TYPE ole2_object , "APPLICATION
macro TYPE ole2_object, "MACRO object
w_book TYPE ole2_object, "list of workbooks
book TYPE ole2_object, "workbook
w_sheet TYPE ole2_object, "list of sheet
sheet TYPE ole2_object, "sheet
seletion TYPE ole2_object, "Selection
value TYPE ole2_object, "value
cell TYPE ole2_object, "cell
cells TYPE ole2_object, "cellS
celle TYPE ole2_object, "cellE
range TYPE ole2_object, "RANGE
font TYPE ole2_object, "font
border TYPE ole2_object, "Border
column TYPE ole2_object, "Column
interior TYPE ole2_object . "Interior
*开始
CREATE OBJECT excel 'EXCEL.APPLICATION'.
SET PROPERTY OF excel 'VISIBLE' = 0. "1 -- Visible, 0 -- invisiable
CALL METHOD OF excel 'Workbooks' = w_book.
CALL METHOD OF w_book 'Open' = book EXPORTING #1 = excel_name .
CALL METHOD OF book 'sheets' = sheet EXPORTING #1 = 1 .
CALL METHOD OF excel 'WORKSheets' = w_sheet
EXPORTING #1 = 'sheet名称'.
CALL METHOD OF w_sheet 'SELECT' .
CALL METHOD OF excel 'Cells' = cell EXPORTING #1 = i #2 = j.
CALL METHOD OF cell 'Value' = val .
SET PROPERTY OF book 'Saved' = 1.
CALL METHOD OF excel 'Quit'.
FREE OBJECT excel .
FREE OBJECT book .
FREE OBJECT sheet .
TYPE-POOLS ole2.
DATA: excel TYPE ole2_object, "Excel object
app TYPE ole2_object , "APPLICATION
macro TYPE ole2_object, "MACRO object
w_book TYPE ole2_object, "list of workbooks
book TYPE ole2_object, "workbook
w_sheet TYPE ole2_object, "list of sheet
sheet TYPE ole2_object, "sheet
seletion TYPE ole2_object, "Selection
value TYPE ole2_object, "value
cell TYPE ole2_object, "cell
cells TYPE ole2_object, "cellS
celle TYPE ole2_object, "cellE
range TYPE ole2_object, "RANGE
font TYPE ole2_object, "font
border TYPE ole2_object, "Border
column TYPE ole2_object, "Column
interior TYPE ole2_object . "Interior
*开始
CREATE OBJECT excel 'EXCEL.APPLICATION'.
SET PROPERTY OF excel 'VISIBLE' = 0. "1 -- Visible, 0 -- invisiable
CALL METHOD OF excel 'Workbooks' = w_book.
CALL METHOD OF w_book 'Open' = book EXPORTING #1 = excel_name .
CALL METHOD OF book 'sheets' = sheet EXPORTING #1 = 1 .
CALL METHOD OF excel 'WORKSheets' = w_sheet
EXPORTING #1 = 'sheet名称'.
CALL METHOD OF w_sheet 'SELECT' .
CALL METHOD OF excel 'Cells' = cell EXPORTING #1 = i #2 = j.
CALL METHOD OF cell 'Value' = val .
SET PROPERTY OF book 'Saved' = 1.
CALL METHOD OF excel 'Quit'.
FREE OBJECT excel .
FREE OBJECT book .
FREE OBJECT sheet .