We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose.Words.Layout Namespace Link


link is broken. also, could you please provide a simple example? Thanks!


Please find below the link where you can study the Aspose.Words.Layout Namespace.


Hello @awais.hafeez, would you be so kind to provide a simple example on how to check if a cell will wrap text? Thanks!


You can use the CellFormat.WrapText property. If you set it to true, then cell will wrap text.

@awais.hafeez Thanks for the response. But I’m asking for checking whether a cell is wrapped and not enable/disabling it to wrap. For example if I have a cell and it contains a text too long that caused it wrap, which property or function should I use to know that it actually wrapped?


I think, you can build logic on the following code to calculate number of lines in Paragraphs. If a Paragraph in Cell has more than one line, then it is wrapped text:

Document document = new Document("D:\\Temp\\input.doc");

var collector = new LayoutCollector(document);
var it = new LayoutEnumerator(document);

foreach (Paragraph paragraph in document.GetChildNodes(NodeType.Paragraph, true))
    var paraBreak = collector.GetEntity(paragraph);

    object stop = null;
    var prevItem = paragraph.PreviousSibling;
    if (prevItem != null)
        var prevBreak = collector.GetEntity(prevItem);
        if (prevItem is Paragraph)
            it.Current = collector.GetEntity(prevItem); // para break
            it.MoveParent();    // last line
            stop = it.Current;
        else if (prevItem is Table)
            var table = (Table)prevItem;
            it.Current = collector.GetEntity(table.LastRow.LastCell.LastParagraph); // cell break
            it.MoveParent();    // cell
            it.MoveParent();    // row
            stop = it.Current;
            throw new Exception();

    it.Current = paraBreak;

    // We move from line to line in a paragraph.
    // When paragraph spans multiple pages the we will follow across them.
    var count = 1;
    while (it.Current != stop)
        if (!it.MovePreviousLogical())

    const int MAX_CHARS = 16;
    var paraText = paragraph.GetText();
    if (paraText.Length > MAX_CHARS)
        paraText = $"{paraText.Substring(0, MAX_CHARS)}...";

    Console.WriteLine($"Paragraph '{paraText}' has {count} line(-s).");

Hope, this helps.