0049-89-49053501 support@wptools.de
20by20table

WPTools: How to quickly create and print a multiplication table

This Topic discusses three possible ways to create and display tabular data in WPTools.

As a fairly simple yet useful example a calculation table should be created. All numbers in the range from 1 to 2 should be multiplied with each other. The square numbers should be bold and the output should be right aligned.

With WPTools just a few lines are required to print such a table and printing can be done by calling the function “Print”.

The first example also features the programmatic activation of paragraph borders and the creation of tabstops.

This is the output:
20by20table

And here I show the Pascal code which puts each multiplication line from 1 to 20 into a single paragraph:

But what about tables? They can also be created quite easily with WPTools.
To solve a problem like this I modified the code above to subsequently fill a table.

With the code above you will probably notice that it takes some time to get executed. The reason for that is that InputString actually simulates keyboard input. The component delays the reformat of the text to the time when all code has been processed, but still, inserting text through InputString is not the fastest.

Fortunately it is easy and straight forward to create real low level code which works with the WPTools paragraphs (also cells are instances of TParagraph) directly.

It is also possible to set styles directly:

Create a style, sid is an integer variable.

The style ID can be assigned to the Style property of any paragraph or cell.

The code below works with low level table creation. It is executed basically instantly.
It does not matter if the I loop goes up to 20, 200, or even 1000.
In the last case it would create over 90 pages and display them the moment the button was pressed!

The code above also uses a special property: WPRichText1.ActiveText. This is the layer which currently has the cursor focus. It can be the body text, a header or footer text, or, with the Premium edition, also a footnote or textbox. It is an instance of the class “TWPRTFDataBlock“.