The Table class, a dynamic feature within the OpenXMLOffice.Presentation library, provides developers with a robust toolset for effortlessly incorporating tables into PowerPoint presentations. This class offers extensive support for diverse table configurations, allowing users to create, modify, and enhance tables in a slide with ease. Developers can leverage the Table class to add new tables.
Basic Code Sample
Section titled “Basic Code Sample”Slide slide = powerPoint.AddSlide(PresentationConstants.SlideLayoutType.BLANK);slide.AddTable(CreateTableRowPayload(10), new TableSetting(){ name = "New Table", widthType = TableSetting.WidthOptionValues.PERCENTAGE, tableColumnWidth = new() { 80, 20 }, x = (uint)G.ConverterUtils.PixelsToEmu(10), y = (uint)G.ConverterUtils.PixelsToEmu(10)});TableSetting Options
Section titled “TableSetting Options”| Property | Type | Details |
|---|---|---|
| name | string | Table Internal name for reference. Default: Table 1 |
| height | uint | Table overall height in EMU. |
| width | uint | Table overall width in EMU Default : 8128000 |
| x | uint | This parameter precisely determines the X position of the entire chart. Default: 0 |
| y | uint | This parameter precisely determines the Y position of the entire chart. Default : 0 |
| widthType | WidthOptionValues | This parameter affects how value in |
| tableColumnWidth | List<float> | The float value is accessed or ignored based on
|
TableRow Options
Section titled “TableRow Options”| Property | Type | Details |
|---|---|---|
| height | int | Configures row height, measured in EMU (English Metric Unit). |
| rowBackground | string? | Configure row background color using hex code (without #). |
| textColor | string | Configure row text color using hex code (without #). |
| tableCells | List<TableCell> | Contains the list of cell that needs to be inserted into the current row. |
TableCell Options
Section titled “TableCell Options”| Property | Type | Details |
|---|---|---|
| value | string? | Value of specific table cell |
| rowSpan | uint | Number of cell Rows of same column to be merged |
| columnSpan | uint | Number of cell Columns to be merged in same row |
| horizontalAlignment | HorizontalAlignmentValues? | Horizontal alignment property |
| verticalAlignment | VerticalAlignmentValues? | Vertical alignment property |
| borderSettings | TableBorderSettings | Table Border setting options |
| cellBackground | string? | Cell Specific background color |
| textColor | string | Cell Specific text color |
| fontFamily | string | Cell Specific font family |
| fontSize | int | Cell Specific font size |
| isBold | bool | Set cell content bold |
| isItalic | bool | Set cell content Italic |
| isUnderline | bool | Set cell content underline status |
TableBorderSettings Options
Section titled “TableBorderSettings Options”| Property | Type | Details |
|---|---|---|
| leftBorder | TableBorderSetting | Left Border Related Setting |
| topBorder | TableBorderSetting | Top Border Related Setting |
| rightBorder | TableBorderSetting | Right Border Related Setting |
| bottomBorder | TableBorderSetting | Bottom Border Related Setting |
| topLeftToBottomRightBorder | TableBorderSetting | TODO |
| bottomLeftToTopRightBorder | TableBorderSetting | TODO |
TableBorderSetting Options
Section titled “TableBorderSetting Options”| Property | Type | |
|---|---|---|
| showBorder | bool | Set border status |
| borderColor | string | Set border color |
| width | float | Set border width |
| borderStyle | BorderStyleValues | Border line style |
| dashStyle | DrawingPresetLineDashValues | Border dash style |
WidthOptionValues *Width Type additional Details
Section titled “WidthOptionValues *Width Type additional Details”| Option | Behavior |
|---|---|
| AUTO | Ignore User Width value and space the column equally. |
| EMU | (English Metric Units) Direct PPT standard Sizing 1 Inch * 914400 EMU’s |
| PIXEL | Based on Target DPI the pixel is converted to EMU and used when running |
| PERCENTAGE | 0-100 Width percentage split for each column |
| RATIO | 0-10 Width ratio of each column |