如何读取excel文件中的多个图片(50)

  • 主题发起人 yfoxyfox
  • 开始时间
Y

yfoxyfox

Unregistered / Unconfirmed
GUEST, unregistred user!
delphi读取excel文件,文件中包含多个图片,如何处理?var i, j, idx: Integer; AExcel, ASheet: Variant; sText: string;begin try AExcel := CreateOleObject('Excel.Application'); try AExcel.DisplayAlerts := False; AExcel.Workbooks.Open('E:/Temp/test.xls'); for i := 1 to AExcel.Workbooks.Count do begin ASheet := AExcel.Worksheets;//读图片(Pictures) for j := 1 to ASheet.Pictures.Count do begin //看不到count数量 ASheet.Pictures[j].Copy; //虽然有多个图片,但是j>1时报错 if Clipboard.HasFormat(CF_PICTURE) then begin Clipboard.Open; try Image1.Picture.Assign(Clipboard); //借助于剪贴板 finally Clipboard.Close; end; end; end; end; finally AExcel.Quit; AExcel := Unassigned; end; except on E: Exception do ShowMessage(E.Message); end;
 
你的代码在我这里运行没有问题(d2006+excel2007)不过,你可以试下下面的代码。for j := 1 to ASheet.Shapes.Count do begin ASheet.Shapes.Item(j).Copy; 或者for j := 1 to ASheet.Pictures.Count do begin ASheet.Pictures.Item(j).Copy;
 

Similar threads

I
回复
0
查看
497
import
I
I
回复
0
查看
589
import
I
I
回复
0
查看
690
import
I
顶部