读立写生 2018-03-22
call method of sheetname 'saveas' exporting # = filepath # =. call method of applicationname 'quit'.
1 call method of sheetname 'name' = 'sheetname'.
1 call method of XXX 'excel.application'.
1 set property of XXX 'visible' = 1. 前台运行。为0时表示为后台运行。
CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOK . call method of workbook 'ADD'.
CALL METHOD OF applicationname 'sheets' = worksheet. call method of worksheet 'Add' .
陈辉/2018-03-22/09:23:27
CaLL METHOD OF EXCEL 'CELLS' = CELL EXPORTING # = # = . Set PROPERTY OF CELL 'value' = xxxx.
CALL METHOD OF applicationname 'Worksheets' = SHEET EXPORTING # = 'sheet3'. 这里sheet3为要操作的sheet的名字。 call method of sheet 'Activate '.
CALL METHOD OF applicationname 'Range' = range EXPORTING # = 'B2' # = 'c2'.
1 call method of range 'select '. range也为已经定义好的ole2_object. 2 Set PROPERTY OF range 'MergeCells' = 0 . 合并单元格,0时不合并,1则合并。与前面一起使用 3 Set PROPERTY OF range 'HorizontalAlignment' = 10 . 4 Set PROPERTY OF range 'VerticalAlignment' = -4108 .
call method of cell 'INTERIOR' = int. set property of int 'ColorIndex' = color. 颜色 set property of int 'Pattern' = pattern.
call method of CELL 'FONT' = font. set property of font 'BOLD' = bold. set property of font 'SIZE' = size.
call method of CELL 'BORDERS' = BORDERS EXPORTING # = ''. -left -right -top -bottom set property of borders 'Linestyle' = plinestyle . set property of borders 'Weight' = pweight . free object borders. 在此之前应该指定range.
1 call method of sheet 'copy'.2 call method of sheet 'paste'.
在操作sheet时,默认为上次操作的sheet.如果想更换,参考8。
解决办法:
1 CALL METHOD OF h_excel 'COLUMNS' = columnObj 2 EXPORTING 3 #1 = 6. "the column number 4 SET PROPERTY OF columnObj 'ColumnWidth' = 10. 5 SET PROPERTY OF columnObj 'NumberFormat' = '@'.
call METHOD OF workbook 'Open' EXPORTING # = filename+path.
CALL METHOD OF EXCEL 'RUN' EXPORTING # = 'ZMACRO2'.
CALL METHOD OF EXCEL 'Range' = RANGE EXPORTING # = tar_cell # = tar_cell. call METHOD of RANGE 'ClearContents'.
CALL METHOD OF EXCEL 'Range' = RANGE EXPORTING # = sor_cell # = tar_cell. SET PROPERTY OF RANGE 'MergeCells' = .
1SETPROPERTYOF range 'ShrinkToFit' = 0 .2 note: 为0时取消缩小字体填充,为1时设置缩小字体填充。
1.与ole相关的关键字存储在表oleload中。
2.如果有些ole方法不熟悉,可以利用vba录制宏来寻找相关的关键字。