PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • Handling a Table by programming
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Inserts a table into a Word Processing control.
Example
// 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)
Syntax
<Result> = <Word Processing control>.InsertTable(<Position> [, <Number of columns> [, <Number of rows>]])
<Result>: docFragment variable
Versions 24 and later
docFragment variable with the inserted fragment.
New in version 24
docFragment variable with the inserted fragment.
docFragment variable with the inserted fragment.
<Word Processing control>: Control name
Name of 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.
Remarks

Handling a Table by programming

A table in a Word Processing document can be handled by the WLanguage functions for managing arrays.
Some examples:
// 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
RETURN
END
 
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'm 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..ParagraphIndex)
Example for creating a table in a document with the content of a Table control:
// A window contains a memory Table control 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 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]
END
END
BREAK
END
END
 
// Document in memory assigned to the Word Processing control
WP_Demo = MyDoc
Component : wd250mdl.dll
Minimum version required
  • Version 23
This page is also available for…
Comments
Click [Add] to post a comment