|
|
|
|
|
- Handling a Table programmatically
DocInsertTable (Function) In french: DocInsèreTableau Inserts a table into a Word Processing document ir replaces the specified fragment with a new table.
DocInsertTable(WP_Table, 1, 3, 3)
DocInsertTable(WP_Table, WP_Table.Cursor, 3, 2)
Syntax
Inserting a table into a Word Processing document Hide the details
<Result> = DocInsertTable(<Document> , <Position> [, <Number of columns> [, <Number of rows>]])
<Result>: docFragment variable docFragment variable with the inserted fragment. <Document>: Document or string variable Document to use. This document corresponds to: <Position>: Integer Position where the table will be inserted. This position is expressed in number of characters. <Number of columns>: Optional integer Number of columns in the table. This parameters corresponds to 1 by default. <Number of rows>: Optional integer Number of rows in the table. This parameters corresponds to 1 by default.
Replacing the existing fragment by a new table Hide the details
<Result> = DocInsertTable(<Fragment> [, <Number of columns> [, <Number of rows>]])
<Result>: docFragment variable docFragment variable with the inserted fragment. <Fragment>: docFragment variable Name of the docFragment variable that corresponds to the fragment to handle. The current fragment content will be replaced with the created table. <Number of columns>: Optional integer Number of columns in the table. This parameters corresponds to 1 by default. <Number of rows>: Optional integer Number of rows in the table. This parameters corresponds to 1 by default. Remarks Handling a Table programmatically A table in a Word Processing document can be handled by the WLanguage functions for managing arrays. For example: Example:
DocInsertTable(WP_ExampleWP, 1, 3, 3)
f is docFragment(TT_ExampleTT.Value, TT_ExampleTT.Cursor, 0)
let para <- f.Paragraph[1]
IF para.Table = Null THEN
RETURN
END
doc is Document <- WP_ExampleWP.Value
nIndex is int = Add(para.Table.Rows)
para.Table.Cells[2,2].Content.Text = "I am in cell 2,2"
Delete(para.Table.Rows, 3)
Delete(para.Table.Columns, 3)
Delete(doc.Paragraph, para.ParagraphSubscript)
Example for creating a table in a document with the content of a Table control:
MyDoc is Document
cTable is Control <- TABLE_Demo
pCol is Control
FragmentStart is docFragment(MyDoc,1)
FragmentStart.Formatting.FontSize = 24
FragmentStart.Formatting.TextColor = DarkRed
FragmentStart.Text = "Table in WP with " + cTable.Caption + CR + CR
DocInsertTable(MyDoc, 20, TableCount(cTable, toColumn), cTable.Occurrence + 1)
FOR EACH para OF MyDoc.Paragraph
IF para.Table <> Null THEN
FOR nColumn = 1 _TO_ TableCount(cTable, toColumn)
pCol <- TableEnumColumn(cTable, nColumn)
para.Table.Cells[1, nColumn].Content.Text = pCol.Caption
FOR nRow = 1 _TO_ cTable.Occurrence
para.Table.Cells[nRow+1, nColumn].Content.Text = pCol[nRow]
END
END
BREAK
END
END
WP_Demo = MyDoc
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|