Identify a cell where a picture is located in worksheet

Hi, everyone.


I have mapped in a SQL table some cells I need to get some information in a worksheet.

For Example:
-------------------------------------------------------------
Information Worksheet Cell
-------------------------------------------------------------
NAME 1 A3
-------------------------------------------------------------
I am getting some difficulties when it comes to map images because they do not have a determined cell in excel worksheet.

Today I am using a foreach statement to go through all pictures in the worksheet as shown below:

foreach (Aspose.Cells.Picture pic in wb.Worksheets[0].Pictures)
{
\get picture information
}

The problem is that the pictures are listed randomly and are not associated with an specific cell.

I tried to use LINKEDCELL property but it is always null.

I tried to use the index of picture as reference to map it but it is variable because the order can input the picture in worksheet ramdomly.

So, Anyone can help me with some questions about aspose.Cells:

1) Is there any way to map a picture by a cell in worksheet?

2) If the answer for the question 1 is NO, do you have any suggestion how I can identify each picture in a worksheet?

Thanks in advance



Hi,


Thanks for providing us some details.

Well, the pictures in the worksheet can be spanned on multiple cells, so you might not determine if a single cell contains the picture or not due to its height/width and placement type. To know about in which cell(s) a picture is placed, you may try to use the following properties of the Shape (Picture) class:
i.e.,
LowerRightColumn, LowerRightRow and UpperLeftColumn, UpperLeftRow, etc.

See the following sample code segment for your reference:
e.g
Sample code:

Picture pic = worksheet.Pictures[index];
int upperColumn = pic.UpperLeftColumn;
int upperRow = pic.UpperLeftRow;
string cellName = CellsHelper.CellIndexToName(upperRow, upperColumn);

Thank you.