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.StartTable();
DocBuilder.RowFormat.LeftIndent = 30;
DocBuilder.Font.Bold = false;
DocBuilder.Font.Size = 12;
// Text Cell
DocBuilder.InsertCell();
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;
DocBuilder.Write(Text);
// Data Cell
DocBuilder.InsertCell();
DocBuilder.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
DocBuilder.CellFormat.Width = 200;
DocBuilder.EndRow();
DocBuilder.EndTable();
}