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

Free Support Forum - aspose.com

How to create fixed column width table using C#

I tried with autofitto windows , content and fixedwidth
also with builder.CellFormat.PreferredWidth = PreferredWidth.FromPoints(40);
In windows fit too im getting issue like
Example : conisder table Expected output in document
column 1 || column 2 || column3
textvalue value || textdata value || column3 value

Current output in document
column 1 || column 2 || column3
textvalue || textdata || column3
value || value || value

How to set column to display in single line with column width adjusting please suggest with code sample.Current,Expected output.zip (18.6 KB)

@saranyasrinivasan92

We suggest you please read the following article and create the “Fixed Column Width” table.
Specifying Table and Cell Widths

Following code example creates a table with three fixed width columns. Hope this helps you.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Table table = builder.StartTable();

// Insert a cell
builder.InsertCell();
builder.CellFormat.Width = 150;
builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
builder.Write("This is row 1 cell 1");

// Use fixed column widths
table.AutoFit(AutoFitBehavior.FixedColumnWidths);

// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 3");
builder.EndRow();

// Insert a cell
builder.InsertCell();

builder.Write("This is row 2 cell 1");

// Insert a cell
builder.InsertCell();
builder.Write("This is row 2 cell 2");

// Insert a cell
builder.InsertCell();
builder.Write("This is row 2 cell 3");
builder.EndRow();
builder.EndTable();

doc.Save(MyDir + "20.6.docx");