excel文件,最常用的一些OLE 知识如下:
冻结列或行
call method of excel_obj 'Range'= range_obj
exporting #1= 'D4'.
call method of range_obj 'Select' .
call method of excel_obj 'ActiveWindow' =window_obj.
set property of window_obj 'FreezePanes' =1.
此代码将excel从前三列和前三开始将窗体冻结
隐藏列
callmethod of excel_obj 'Columns' = column_obj
exporting #1= 'E:I' .
call method of column_obj 'Select' .
set property of column_obj 'Hidden' = 1.
增加批注
call method of excel_obj 'Range'= range_obj
exporting #1 = 'B5' .
call method of range_obj 'Select' .
call method of range_obj 'AddComment' exporting#1 = '系统注释:你可以查看zmb51'.
设置背景
call method of sheet_obj 'Range' = range_objexporting #1 = 'B5' .
call method of range_obj 'Interior' =Interior_obj.
set property of Interior_obj 'ColorIndex' = 3.
合并单元格
form set_cell_union using i j val.
CALL METHOD OF excel_obj 'Range' =range_obj
EXPORTING #1= i #2 = j .
SET PROPERTY OF range_obj 'MergeCells' =1.
SET PROPERTY OF range_obj 'Value' = val .
endform.
运行宏
perform runmacro using 'deleteRows'.
FORM runmacro USING macroname.
CALL METHOD OF excel_obj 'RUN'
EXPORTING
#1 = macroname.
ENDFORM.
设置边框(设置区域边框)
FORM set_cell_border2 using s e w.
CALL METHOD OF excel_obj 'Range' =range_obj
EXPORTING #1 = s
#2 = e.
GET PROPERTY OF range_obj 'Borders' =borders_obj .
SET PROPERTY OF borders_obj 'LineStyle' = '1'.
* SET PROPERTY OF borders_obj 'WEIGHT' =w.
FREE OBJECT borders_obj.
ENDFORM.