• Handling a Table through programming
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WindowsLinuxPHPWEBDEV - Browser code
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Stored procedures
Inserts a table into a Word Processing control.
// Inserts a 3x3 table at position 1
WP_Table.InsertTable(1, 3, 3)
// Inserts a table containing 3 columns and 2 rows at cursor position
WP_Table.InsertTable(WP_Table.Cursor, 3, 2)
<Result> = <Word Processing control>.InsertTable(<Position> [, <Number of columns> [, <Number of rows>]])
<Result>: docFragment variable
docFragment variable with the inserted fragment.
<Word Processing control>: Control name
Name of the Word Processing control to use.
<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.

Handling a Table through programming

A table in a Word Processing document can be handled by the WLanguage functions for managing arrays.
For example:
// Retrieve the document
MyDocument is Document <- WP_ExampleWP
// Inserts a 3x3 table at position 1
WP_Example.InsertTable(1, 3, 3)
// Define a fragment corresponding to the table
f is WP_Example WP.Value.Fragment(WP_ExampleWP.Cursor, 0)
let para <- f.Paragraph[1]
IF para.Table = Null THEN
doc is Document <- WP_ExampleWP.Value
// Adds a row to the table
nSubscript is int = Add(para.Table.Rows)
// Input in cell 2,2
para.Table.Cells[2,2].Content.Text = "I am in cell 2,2"
// Deletes row 3
Delete(para.Table.Rows, 3)
// Deletes column 3
Delete(para.Table.Columns, 3)
// Deletes the entire table where the cursor is positioned
Delete(doc.Paragraph, para.ParagraphSubscript)
Example for creating a table in a document with the content of a Table control:
// A window contains a Table control populated programmatically named TABLE_Demo
// and a Word Processing control named WP_Demo
// The following code adds a table into the Word Processing control with:
// - in first table row, the title of columns found in the Table control,
// - the content of Table control in the other table rows.
MyDoc is Document
cTable is Control <- TABLE_Demo
pCol is Control
FragmentStart is MyDoc.docFragment(1)
FragmentStart.Formatting.FontSize = 24
FragmentStart.Formatting.TextColor = DarkRed
FragmentStart.Text = "Table in WP with " + cTable.Caption + CR + CR
// Insert the table into the document in memory ...
MyDoc.DocInsertTable(20, TableCount(cTable, toColumn), cTable.Count + 1)
FOR EACH para OF MyDoc.Paragraph
IF para.Table <> Null THEN
// For all columns of the Table control ...
FOR nColumn = 1 _TO_ TableCount(cTable, toColumn)
// First tab le line containing the title of columns
pCol <- TableEnumColumn(cTable, nColumn)
para.Table.Cells[1, nColumn].Content.Text = pCol.Caption
// Fill all rows of this column
FOR nRow = 1 _TO_ cTable.Occurrence
para.Table.Cells[nRow+1, nColumn].Content.Text = pCol[nRow]
// Document in memory assigned to the Word Processing control
WP_Demo = MyDoc
Component: wd280mdl.dll
Minimum version required
  • Version 23
This page is also available for…
Click [Add] to post a comment