How to: Create a Table with Fixed Column Width
To create a table with fixed column widths, specify the following settings as shown in the code sample below.
Table Element | Property | Value |
---|---|---|
Table | ||
Cell |
A floating point value specifying the cell width. To avoid dimensional changes at runtime, convert this value to document units of measurement (determined by the Document. |
Note
A complete sample project is available at https://github.
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);
The image below illustrates the result of the code execution.