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

Free Support Forum - aspose.com

Table Cell Auto Fit in Aspose Words

I am generating a word document dynamically that is a print out of a survey. I am using tables with different border attributes to create the questions and an underlined space for the answers. I need the cells containing the question text to resize to fit the text, but I need the underline cells to be a fixed size.

Is it possible to create a table row where some cells have a fixed width and other cells are auto fit to their contents? I have tried using "RowFormat.AllowAutoFit = true" and "CellFormat.WrapText = false" but the text still wraps and the cell does not autofit. I want the text to stay on one line. Is there a way to set the cell width to auto or default? I am setting the cell width to 0 to avoid keeping the width from the previous cell.

Function I am calling repeatedly to build the document:

public void AddFillIn(string Text)
//for question on one line
DocBuilder.ParagraphFormat.LeftIndent = 0;
DocBuilder.RowFormat.LeftIndent = 30;
DocBuilder.Font.Bold = false;
DocBuilder.Font.Size = 12;
//Text Cell
DocBuilder.CellFormat.Borders.LineStyle = LineStyle.None;
DocBuilder.CellFormat.WrapText = false;
DocBuilder.RowFormat.AllowAutoFit = true;
//reset the width to zero to avoid keeping the width at 200
DocBuilder.CellFormat.Width = 0;
//Data Cell
DocBuilder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
DocBuilder.CellFormat.Width = 200;


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Unfortunately, there is no way to specify “Auto-fit to content” option of table cell using Aspose.Words. I linked your request to the appropriate issue; you will be notified as soon as this feature is supported.

Currently, you can only specify fixed width of table cells.

Best regards,

Hi there
I am currently encountering the same issue as I transform some html tables into word using DocBuilder from Aspose.Words. Is there a way to apply an auto - adjustment for the optimal column width’s according to the text given? Just like the Layout ->AutoAdjust in Word?

Dear greetings
Samuel Lörtscher


Thanks for your request. Maybe the code example provided here could help you:


Best regards,

The issues you have found earlier (filed as WORDSNET-2044) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.