delphi使用循环语句向EXCEL插入多个图片,为何只有最后一张图片的大小是指定的大小?而前面插入的图片都变了形一样,不正常,但如果单独插入一张图片却很正常? 请问各位前辈,这是为何?                                                       小弟在此候教!

解决方案 »

  1.   

    var pict:variant; excelapp:variant; ptop,i,shiyh:integer;
    beginexcelapp := createoleobject( 'excel.application' );
      excelapp.visible :=false;
      excelapp.workbooks.add;
      excelapp.worksheets[1].activate;// 插入图片
                             //
    ptop:=10;       //ptop 此处用作插入图片座标的TOP点
    shiyh:=10;     //该变量为插入图片总数for i:=1 to shiyh do        
    begin//excelapp.activesheet.pictures.insert(GetCurrentDir+'\fhclPict\试验图'+inttostr(i)+'.wmf');   
    //pict:=excelapp.activesheet.pictures;                //此处两句为之前所使用的
                                                          //即出现问题中所述情况pict:=excelapp.activesheet.pictures.insert(GetCurrentDir+'\fhclPict\图'+inttostr(i)+'.wmf');   
    //正常插入的语句
    pict.top:=ptop;
    pict.left:=10;
    pict.width:=450;
    pict.height:=250;//pict:=null;
     if (i mod 2)=0 then
      ptop:=ptop+280
     else
      ptop:=ptop+275;
    end;
    excelapp.visible :=true;
    end;