Report Builder FastReport .Net User Guide: TEXT Text Editing

FastReport .Net is a full-featured Windows Forms, ASP.NET and MVC report analysis solution. Using FastReport .NET can create .NET reports independent of applications. At the same time, FastReport .Net supports 14 languages ​​such as Chinese and English. You can make your products truly international.

TEXT text editor

In the previous article of the Fastreport User Manual, we shared the "Text" object. This article mainly shares text editing, hoping to help you.

Text editing is all about editing the text of an object, just double-click it. You'll see a text editor:

This is like having a data tree on the right side of the editor, and elements can be added to the text. This can be done by using the mouse to drag the element to the desired position. Another way to insert an element into text is to double click on the element and it will be added at the cursor's current position.

To save changes and close the editor window, click the OK button or press Ctrl+Enter.

Another way to edit text - in-place editing. To do this, select the "Text" object and press the Enter key. To finish editing, click somewhere outside the object's boundaries or press Ctrl+Enter. Press the Esc key to cancel the changes. When editing an object in place, you can change its size with the mouse.

show expression

"Text" objects can contain plain text mixed with expressions. For example:

Today is [Date]

When printing such objects, all expressions contained in the text are evaluated. So the result could be something like this:

Today is 12.09.2010

Expressions are identified by square brackets as shown. This is set in the "Brackets" property, which by default contains the string "[,]". When needed, you can use a different set of symbols, such as "<,>" or "<!,!>". In the last case, the expression in the text will look like this:

Today is <!Date!>

Apart from that, all expressions can be disabled. To do this, set the AllowExpressions property to false. In this case the text will be displayed "as is".

Inside the square brackets, you can use any valid expression. Read more about expressions in the "Expressions" article later in the guide. For example, an object with the following text:

2 * 2 = [2 * 2]

will print like this:

2 * 2 = 4

Common Mistake - Trying to write an expression outside the square brackets. As a reminder, it is considered an expression, and only the expression enclosed in square brackets is executed. For example:

2 * 2 = [2] * [2]

This text will be printed this way:

2 * 2 = 2 * 2

There may be some elements in the expression that require their own square brackets. For example, it might be a reference to a system variable. Let's look at the following example:

The next page: [[Page] + 1]

The text contains an expression [Page] + 1 .Page is a system variable that returns the number of the current report page. It is enclosed in its own parentheses. These brackets must be square brackets regardless of the "text" object setting.

Strictly speaking, when using the "Date" system variable in the above example, we should use two square brackets:

Today is [[Date]]

However, FastReport allows to omit a pair of unnecessary parentheses if there is only one member in the expression.

Display data columns, HTML tags

Show Data Columns

You can print columns of data via:

[Datasource name.Column name]

As you can see, square brackets are used here. Data source names and data column names are separated by periods. For example:
[Employees.FirstName]
has several methods to insert columns of data into the "text" object.

  • In the editor of the "Text" object, we manually write the names of the data columns. This method is the most inconvenient and error-prone.
  • In the object's editor, we select the desired data column and drag and drop it to the text:

Click the small button in the upper right corner of the object and select the data column from the list:

Drag and drop data columns from the Data window onto the report page. In this case, a "text" object is created containing a link to the column.

HTML tags

You can use some simple HTML tags in the "text" object. Tags are disabled by default; to enable it, go to the Properties window and set the "HtmlTags" property to true. Here is a list of supported tags:

Label describe
<b>...</b> Bold font.
<i>...</i> Italic text.
<u>...</u> Underlined text.
<strike>...</strike> Strikethrough text.
<child>...</child> subscript.
<sup>...</sup> Superscript.
<font color=...>...</font> font color. The color can be a specified color (such as DarkGray), or a hex code in #RGB format, such as #FF8030.

The following examples demonstrate how to use these tags.

text <b>bold text</b> <i>text in italic</i> <b><i>bold and in italic</b></i>
E = mc<sup>2</sup>
A<sub>1</sub> = B<sup>2</sup>
this is regular text, <font color=red>and this is a red one</font>
this is regular text, <font color=#FF8030>and this is an orange one</font>

This text will be displayed as follows:

Properties of the "Text" object
Attributes describe
allow expressions This property allows expression processing to be turned on or off. It is on by default.
angle This property indicates the text rotation, in degrees.
auto shrink This property allows to automatically reduce the font size or font width to fit the text.
Auto Shrink Minimum Size If the AutoShrink property is used, this property determines the minimum font size or minimum font-to-width ratio.
auto width This property allows automatic calculation of the object's width.
brackets This property contains a pair of symbols that specify an expression.
to interrupt Using this property, you can organize the flow of text from one text object to another. For example, we have "A" and "B" text objects. The 'A' object contains long text that does not fit within the boundaries of the object. You can set A.BreakTo to B, so the "B" object will display the part of the text that doesn't fit in "A".
prune This property determines whether it is necessary to clip text outside the bounds of the object. It is on by default.
repeat This property determines how duplicate values ​​are printed.
FirstTabOffset This property determines the offset, in pixels, of the first TAB symbol.
character aspect ratio Use this property to make fonts wider or narrower. By default, this property is set to 1. To make the font wider, set the value of this property to > 1. To make the font narrower, set this property to a value between 0 and 1.
hidden value This attribute is of type string. It allows to hide values ​​equal to the value of this property.
hide zero This property allows zero values ​​to be hidden.
emphasize This property allows setting conditional highlighting.
horizontal alignment, vertical alignment These properties determine the text alignment.
HTML tags Allows simple HTML markup in the object's text.
line height This property allows to explicitly set the height of a line of text. By default it is set to 0, so the default line spacing is used.
empty value Text that will be printed instead of null. You also need to uncheck the "Convert Null Values" option in the "Report/Options..." menu.
filling This property allows to set the padding in pixels.
right to left This property indicates whether the text should be displayed in right-to-left order.
label width This property determines the width of the TAB symbol in pixels.
text This property contains the text of the object.
text fill This property determines the text padding. Use this attribute editor to choose between different fill types.
prune This property determines how text that does not fit within the object's boundaries is trimmed. It is only used when the "WordWrap" property is set to false.
underline This property allows lines of graphics to be displayed after each line of text. This property can only be used if the text is top-aligned.
word wrap 此属性确定是否需要按单词换行文本。
Wysiwyg 此属性更改“Text”对象的显示模式以匹配屏幕和最终打印输出。如果您使用 justify-align 或非标准行高,也会使用此模式。

Guess you like

Origin blog.csdn.net/m0_67129275/article/details/131695221