Cell text width

Hello,
I need to find length of the text in the cell in pixels. Not cell width but actual text inside cell width in pixels. I spend more than 3 hours looking how to get it but unsuccessfully. If you could help me with that I would appreciate very much
Thanks
Alikas

Hi,

Thanks for your posting and using Aspose.Cells.

First you will insert text in a separate worksheet in cell A1 and then call autofitcolumns which will widen the width of column A as per text. Then you will get the width of the column using on the following functions.

  • GetColumnWidth
  • GetColumnWidthInch
  • GetColumnWidthPixel

See the topic for your reference.
http://www.aspose.com/docs/display/cellsnet/Adjusting+Row+Height+and+Column+Width

Hello,

I know that I can use autofitcolumns. and I know this methods:

  • GetColumnWidth
  • GetColumnWidthInch
  • GetColumnWidthPixel
  • But that's not what I wanted to find out. I need to find a way how to measure text in the cell.

    Is it any way to measure text width using aspose like Java AWT method:

    java.awt.FontMerics.stringWidth(String str)

    Do you have anything similar in aspose?

    Thank you

    Hi,

    Thanks for your posting and using Aspose.Cells for Java.

    We are afraid, there is no such API in Aspose.Cells which could fit your needs. However, you can use the workaround as suggested by me in the above post.

    When you will use a separate worksheet and insert some text in first cell, auto fit the columns, then cell’s width and text width will be same.