Skip to main content
A newer version of this page is available. .

How to: Create a Table with Fixed Column Width

To create a table with fixed column widths, specify the following settings:

Property Value
For the table set the Table.TableLayout TableLayoutType.Fixed
For the table set the Table.PreferredWidthType WidthType.Fixed
For each cell set the TableCell.PreferredWidthType WidthType.Fixed
For each cell set the TableCell.PreferredWidth A floating point value specifying the cell width measured in document units of measurement determined by the Document.Unit property.
Document document = server.Document;
Table table = document.Tables.Create(document.Range.Start, 3, 3);

table.TableAlignment = TableRowAlignment.Center;
table.TableLayout = TableLayoutType.Fixed;
table.PreferredWidthType = WidthType.Fixed;
table.PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(4f);

table.Rows[1].HeightType = HeightType.Exact;
table.Rows[1].Height = DevExpress.Office.Utils.Units.InchesToDocumentsF(0.8f);

table[1, 1].PreferredWidthType = WidthType.Fixed;
table[1, 1].PreferredWidth = DevExpress.Office.Utils.Units.InchesToDocumentsF(1.5f);

table.MergeCells(table[1, 1], table[2, 1]);