Pictures Class -Getting an image from a cell

hello

I am using Aspose Cells

I want to find out if a cell contains an image

According to the docs I shoukd be able to do the following

Picture pic1 = worksheet.Pictures[5, 5];

where 5, 5 are row and column of the cell

However, the pictures class only takes a single index

e.g. Picture pic1 = worksheet.Pictures[5];

which does not relate to the cell containing the image

I am using 4.6.0.13

Is this something that only exists in later versions of the software?

thanks,

Hi,

Thank you for considering Aspose.

Well, the Pictures collection contains all the pictures in a worksheet and you can access them by specifying them by there index (Worksheet.Pictures[index]). I did not find any API like Pictures[rowIndex,columnIndex] in the documentation, can you please provide the link for the documentation page which you are referring to?

If you want to check whether a particular cell has an image or not, you may check the following APIs of the picture object and see if they fit your need:

Picture.UpperLeftRow;

Picture.UpperLeftColumn;

Picture.LowerRightRow;

Picture.LowerRightColumn;

Thank You & Best Regards,

Hi

Thanks for the reply.

Here’s the documentation with the row and column as an index

Aspose.Total for .NET|Documentation

See the second example under the heading “Accessing pictures”

I have created a helper method using Linq to do similar which I’ve included below
But I would prefer to be able to do something like the example in the docs

Please let me know if that is possible as it is clearly in the documentation
thanks

Worksheet worksheet = workbook.Worksheets[1];

IEnumerable pics = worksheet.Pictures.Cast();

Picture piccy = GetPictureByCoords(pics, 5, 5);

and the helper is this

private Picture GetPictureByCoords(IEnumerable pics, int col, int row)
{
Picture picName = pics.SingleOrDefault((pic => pic.UpperLeftRow == row && pic.UpperLeftColumn == col));

return picName;
}

Hi,

Thank you for considering Aspose.

The document you are referring to is related to Aspose.Cells.GridDesktop control and the API “Pictures[rowIndex,columnIndex]” is in Aspose.Cells.GridDesktop namespace. You cannot use the Pictures APIs of Aspose.Cells.GridDesktop namespace into Aspose.Cells namespace. Both Aspose.Cells & Aspose.Cells Grid Suite have there separate APIs.

Thank You & Best Regards,