Is there way to extract word's coordinates from cell?

Actually my question fully described in the subject. Is there some API for that? I know how to extract cells coordinates. So is there way to extract word coordinates inside cell?


Thanks in advance.

Hi,


Do you need to apply formatting to selected chars in the cell? If yes, you may use Cell.Characters() method accordingly, see the document for your reference:
http://www.aspose.com/docs/display/cellsnet/Formatting+Selected+Characters+in+a+Cell
Moreover, you may also use Cell.GetCharacters() method to obtain all the characters as object (it reruns FontSetting[] array).

And, if you need to get the indexed position of any character in the cell’s text, you may simply use String.IndexOf() method etc.

Thank you.

No. I need x, y coordinates and width, height in pixel. To store in database. So is there way to get word coordinate(x,y, width and height) in pixel?

Hi,


Thanks for providing further details.

Well, I think you may implement DrawObjectEvenHandler interface to write your own codes in its Draw method to override it. The method would give retrieve you DrawObject which you may bind it accordingly for your needs. Please see the sample code below to accomplish your task for your needs for your reference. The code extract the cell’s name, position and size to be printed. Please refer to the code segment and you may build your own handler for your special requirements, you may update the code to override Draw method for your own custom needs accordingly

e.g
Sample code:


public class DE : DrawObjectEventHandler
{
public override void Draw(DrawObject drawObject, float x, float y, float width, float height)
{
Console.WriteLine(drawObject.Cell.Name + “: [” + x + ", " + y + “], [” + width + ", " + height + “]”);
}
}

Workbook workbook = new Workbook(“e:\test2\Bk_extractcoordinates1.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
//Cell cell = worksheet.Cells[“E8”];
ImageOrPrintOptions oooo = new ImageOrPrintOptions();
oooo.DrawObjectEventHandler = new DE();
oooo.ImageFormat = ImageFormat.Png;
SheetRender sr = new SheetRender(worksheet, oooo);
sr.ToImage(0);


Hope, this helps a bit.

Thank you.

I know this question is old but I want to know how to get the coordinates of the text in a cell. The sample code you provided only handles the coordinate for a cell and not the text in it.

@Trickstar,

You may get height and width of the value/string of a cell via Aspose.Cells’ respective methods but we will check if there is some better way to get x/y coordinates of the string value inside a cell. We may get back to you soon.

@Trickstar,

We evaluated your issue further. I am afraid, there is no such API to accomplish your task. Also, we cannot support it either for performance grounds. Moreover, there can also be some other hurdles to implement such requirements. I am afraid, you got to use your own code to get the coordinates of the ext in a cell.

@Amjad_Sahi
Thanks for your reply, I thought maybe you guys had such an API because when I use Aspose to convert an Excel file to an image, the format of each individual text is saved in the image almost exactly as it is in the excel document. So I thought maybe you guys save each text by first getting Fontsettings collection then saving it individually with how the text is fomratted.