PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • 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 a Word Processing document.
Caution: This documentation presents the last features of the Word Processing control. Make sure that all the necessary modules are updated.
Example
// Retrieve the document
MyDocument is Document <- WP_Table

// Inserts a table whose size is 3x3 at position 1
DocInsertTable(WP_Table, 1, 3, 3)
// Retrieve the document
MyDocument is Document <- WP_Table

// Inserts a table containing 3 columns and 2 rows at cursor position
DocInsertTable(WP_Table, WP_Table..Cursor, 3, 2)
Syntax

Inserting a table into a a Word Processing document Hide the details

DocInsertTable(<Document> , <Position> [, <Number of Columns> [, <Number of Rows>]])
<Document>: Document variable or character string (with or without quotes)
Document to use. This document corresponds to:
  • WINDEV the name of a Word Processing control.
  • a Document variable.
<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.
This syntax is available from version 220071.

Replacing the existing fragment by a new table Hide the details

DocInsertTable(<Fragment> [, <Number of Columns> [, <Number of Rows>]])
<Fragment>: docFragment variable
Name of docFragment variable corresponding to the fragment to use. The current fragment content will be replaced by 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 by programming

A table found in a Word Processing control can be handled by the WLanguage functions for array management.
Some examples:
Example:
// Retrieve the document
MyDocument is Document <- WP_ExampleWP
// Inserts a table whose size is 3x3 at position 1
DocInsertTable(WP_ExampleWP, 1, 3, 3)

// Define a fragment corresponding to the table
f is docFragment(WP_ExampleWP..Value, WP_ExampleWP..Cursor, 0)

let para <- f..Element[1]..Paragraph
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 the row 3
Delete(para..Table..Rows, 3)

// Deletes the 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 docFragment(MyDoc,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 ...
DocInsertTable(MyDoc, 20, TableCount(cTable, toColumn), cTable..Occurrence + 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
Components
WINDEVWEBDEV - Server codeReports and Queries wd230mdl.dll
Linux wd230mdl.so
Minimum required version
  • Version 22
This page is also available for…
Comments
Click [Add] to post a comment