Table Features Supported on HTML Import
A table is comprised of rows and cells and is used to display data in a grid-like layout.
Aspose.Words supports imports of tables from all loaded formats including Microsoft Word, Open Office and HTML documents.
A table is represented in Aspose.Words by a Table node. Each row of the table is represented by a separate Row node. Likewise each cell of the row is represented by a Cell node. Each node type has it’s own formatting properties which controls the table’s apperance and behavior.
- Table contains the properties for controlling the formatting of a table as a whole.
- Each Row provides a RowFormat object which contains the properties that control formatting for that particular row.
- Each Cell has a CellFormat object which provides properties to control the formatting of each cell.
Using Aspose.Words you can access and modify all features and formatting of a table along with creating new tables and removing existing ones from the document.
Note that some elements of a table may be wrapped with Markup nodes such as CustomXmlMarkup or StructuredDocumentTag nodes.
A table is imported from source HTML from <table> and other applicable tags.
Currently CSS styles are not imported from table, tr and td elements on import. These feature are planned. You can define inline styles on TD in the mean time.
See the following links in the documentation for further information:
- Working with Tables
- Table
Table
Feature | Supported | Comment | See Also |
---|---|---|---|
Nested Tables | Yes | ||
Right To Left Tables | Yes | - Table.Bidi | |
Table Style | Planned | Table styles are supported in model and during conversion. A table style can be applied or removed from tables. Only in-built or table styles already in the document can be applied - there is currently no support for creating new table styles. There are plans to import CSS style on table as a Table Style. |
- Working with Table Styles - Table.Style - Table.StyleIdentifier |
Conditional Formatting Style | N/A | ||
Table Alignment | Yes | Imported as a table wrapped inside a <div> formatted with text-align. | - Table.Alignment |
Table Indent | Planned | Will be imported from margin-left:XXX on table. Currently this property is skipped. |
- Table.LeftIndent |
Allow AutoFit | Planned | Can be imported from “table-layout:fixed” attribute. | - Table.AllowAutoFit |
Default Cell Margins | Planned | Can be imported from “spacing” style attribute on table. | - Table.LeftPadding - Table.RightPadding - Table.BottomPadding - Table.TopPadding |
Default Cell Spacing | Planned | Can be imported from “padding-left”, “padding-right” etc style attribute on table. | - Table.CellSpacing |
Preferred Table Width | Yes | Preferred width on table can be set to absolute (points), relative (percent) or auto setting. Imported from width as relative (percent) or absolute (point) width from <table>. |
- Table.PreferredWidth |
Table Shading | Yes | Imported from background-color style attribute on all cells in the table. | - Table.SetShading |
Hidden | N/A |
Floating Tables
Floating tables are supported during import and export. However there is currently no API to access or modify the floating position of a table.
Floating tables are imported as inline.
Feature | Supported | Comment | See Also |
---|---|---|---|
Floating Tables | Planned |
Table Borders
Table borders are stored in the rows of the table. This mimics the structure of an OOXML document.
If you try to set borders or shading on a table without any rows then an exception will be thrown. Add at least one row first.
Borders are imported from each cell from style attribute border-XXX-style, border-XXX-color etc.
See the following links in the documentation for further information:
- Table.SetBorders
- Table.ClearBorders
- RowFormat.Borders
Feature | Supported | Comment | See Also |
---|---|---|---|
Table Borders | Planned |
Rows
Feature | Supported | Comment | See Also |
---|---|---|---|
Allow Break Across Pages | Planned | - Keeping Tables and Rows from Breaking across Pages - RowFormat.AllowBreakAcrossPages |
|
Repeat as Header Row | Planned | Will be imported from <thead> and <th> elements. Currently content from such elements are still imported properly but not as header rows. |
- Specifying Rows to Repeat on Subsequent Pages as Header Rows - RowFormat.HeadingFormat |
Height | Yes | Imported from “height” of style attribute on <tr>. Row height is only from <tr> and not from <td> cells. | - RowFormat.Height |
Height Rule | Planned | A row without any height is imported as “Auto” height rule. A row with height defined is imported as “At Least”. |
- RowFormat.HeightRule |
Cells
Feature | Supported | Comment | See Also |
---|---|---|---|
Cell Margins | Yes | Imported from padding-XXX on <td> elements. | - CellFormat.TopPadding - CellFormat.BottomPadding - CellFormat.LeftPadding - CellFormat.RightPadding |
Borders | Yes | Imported from <td> style attribute border-XXX-style, border-XXX-width etc. | - CellFormat.Borders |
Shading | Yes | Imported from “background-color” style attribute on <td>. Note that background-image attribute is not supported as a Cell in a Microsoft Word document does not have a corresponing feature to this>. Instead consider applying the background image to the paragraph inside the cell in the HTML document. |
- CellFormat.Shading |
Wrap Text | Planned | - CellFormat.WrapText | |
Fit Text | Planned | - CellFormat.FitText | |
Preferred Width | Yes | Imported from style attribute width from cells as either relative (percent) or fixed (points). | - CellFormat.PreferredWidth |
Merged Horizontally | Yes | Imported from “row-span” attribute on <td>. | - Working with Merged Cells - CellFormat.HorizontalMerge |
Merged Vertically | Yes | Imported from “col-span” attribute on <td>. | - CellFormat.VerticalMerge |
Vertical Alignment | Yes | Imported from the vertical-align attribute on cell. | - CellFormat.VerticalAlignment |
Text Direction | Yes | Imported from “writing-mode” style attribute. | - CellFormat.Orientation |