您的位置:程序门 -> delphi -> windows sdk/api



用delphi设置excel对图片的操作的问题?


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


用delphi设置excel对图片的操作的问题?[已结贴,结贴人:shylsz]
发表于:2007-01-10 11:26:43 楼主
1添加图片
2改变大小(先选择图片)
3改变位置(先选择图片)
哪位大哥操作过吗?
发表于:2007-01-10 17:17:131楼 得分:0
你把上面的操作用宏录下来,看看vb代码,然后再转成delphi
发表于:2007-01-18 16:40:592楼 得分:0
努力中..
发表于:2007-01-18 18:08:513楼 得分:0
痛苦啊
发表于:2007-01-25 11:26:114楼 得分:0
up
发表于:2007-01-25 16:50:285楼 得分:0
activesheet.shapes( "picture   1 ").select
        selection.shaperange.scalewidth   0.44,   msofalse,   msoscalefromtopleft
        selection.shaperange.scaleheight   0.44,   msofalse,   msoscalefrombottomright
        selection.shaperange.incrementleft   -19.5
        selection.shaperange.incrementtop   -299.25
        selection.shaperange.scalewidth   0.63,   msofalse,   msoscalefromtopleft
        selection.shaperange.scaleheight   0.63,   msofalse,   msoscalefromtopleft
以上是宏代码
怎么转换??
发表于:2007-01-26 09:21:566楼 得分:0
随便写写,没测试

const
    msoscalefromtopleft   =   $00000000;
    msoscalefrommiddle   =   $00000001;
    msoscalefrombottomright   =   $00000002;
    msotrue   =   $ffffffff;
    msofalse   =   $00000000;
var
activesheet,excel:variant;
begin
excel:=createoleobject( "excel.application ");  
excel.workbooks.open( "c:\xxx.xls ");
activesheet:=excel.worksheets( "sheet1 ");
activesheet.activate;
activesheet.shapes( 'picture   1 ').select;
with   activesheet   do
begin
    selection.shaperange.scalewidth(   0.44,   msofalse,   msoscalefromtopleft);
    selection.shaperange.scaleheight(   0.44,   msofalse,   msoscalefrombottomright);
    selection.shaperange.incrementleft:=-19.5;
    selection.shaperange.incrementtop:=-299.25;
    selection.shaperange.scalewidth(0.63,   msofalse,   msoscalefromtopleft);
    selection.shaperange.scaleheight(0.63,   msofalse,   msoscalefromtopleft);
    save;
end;
activesheet:=unassigned;
excel.close;
excel:=unassigned;
end;
发表于:2007-03-08 09:13:467楼 得分:0
楼上的代码编译不通过
发表于:2007-03-08 10:02:558楼 得分:100
uses   comobj;
const
    msoscalefromtopleft   =   $00000000;
    msoscalefrommiddle   =   $00000001;
    msoscalefrombottomright   =   $00000002;
    msotrue   =   $ffffffff;
    msofalse   =   $00000000;
var
excel:variant;
activesheet,activeshapes:variant;
begin
if   not   opendialog1.EXECute   then   exit;
excel:=createoleobject( 'excel.application ');
//打开工作簿
excel.workbooks.open(opendialog1.filename);
//激活第1个表
activesheet:=excel.worksheets[1];
activesheet.activate;
if   opendialog1.EXECute   then   begin
    //添加图片
    activeshapes:=activesheet.shapes.addpicture(opendialog1.filename,true,true,0,0,100,100);
    //选择图片
    activeshapes.select;
    //调整大小
    activeshapes.scalewidth(   0.44,   msofalse,   msoscalefromtopleft);
    activeshapes.scaleheight(   0.44,   msofalse,   msoscalefrombottomright);
    //移动位置
    activeshapes.incrementleft(20);
    activeshapes.incrementtop(20);

    activeshapes:=unassigned;
end;
//保存
excel.save;
//释放excel对象
activesheet:=unassigned;
excel:=unassigned;


快速检索

最新资讯
热门点击