Cannot extract all images from Excel file

I need to extract images and data from an Excel-file.
The Excel file always have the same structure.
When I export all the images in the file, I have several images which are 0 Kb.
The Excel file is included.

The second problem i have is that i need to match the image to the data.
For that i store the rownumber where a new data item starts.
I then loop over the images and look at Anchor.Row1 to get the starting row of the image.
I then match this with the data item that starts 1 row further.
When saving the image i seem to get the previous image.

for i := 1 to xls.ImageCount do
ImageRow := xls.GetImageProperties(i).Anchor.Row1; // .Row1;

Thank yu for having a look at this.


Report.xlsx (1.2 MB)

About the first issue, I used the code here:

And I couldn't see any 0-byte image:

(note that the list is sorted by size, so the smallest one is 2kb). Also they all look like valid images.

About 2, sometimes the problem might be that even when an image looks to be at the top of row n, it is really at the bottom of row (n-1). Visually they look the same.

So you need too look at the DY1 besides the row. Visually, an image at row 1, with a DY1 of 255 looks the same as an image at row 2, DY1 of 0.

But in your case, the images are at the correct rows, and the numbers I get are the correct ones. For example, above, the image is at row 263, and the list shows row 263 as one of the row1 for the images.

I attach the project I used to test here: (1.2 MB)

Hi Adrian,

I'm terribly sorry, i was using the following line of code to get the image:
xls.Getimage(i, '', imageType, ImageStream, true);

yes, the last parameter must be false (or not set at all, which defaults to false). If not, you are using the obectid of the object, not the index of the loop.