Chinaunix首页 | 论坛 | 博客
  • 博客访问: 721388
  • 博文数量: 158
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1643
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-11 14:37
个人简介

人法地,地法天,天法道,道法自然

文章分类

全部博文(158)

文章存档

2022年(1)

2020年(3)

2016年(1)

2014年(7)

2013年(4)

2010年(5)

2009年(86)

2008年(25)

2007年(26)

我的朋友

分类:

2009-05-05 22:48:36

开发在执海关合同,当将进口料件汇总后生成的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从前三列和前三开始将窗体冻结

 

隐藏列

 

  call method 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_obj exporting #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.

 

 

阅读(1175) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~