The caret character (^) can be entered in various text fields on dialogs in the software to indicate a line break. When the text is displayed on the project page drawing, a line feed / new line is inserted in place of the caret character.
However, this functionality of the caret is not recognized by report templates. Therefore, in Run Reports, some template types include a Replace multi-line character(^) with space check box in Options. If this check box is set, the caret will be replaced with a space on the report output. If it is not set, the caret will be left as is. In neither case will the out-of-the box software replace the caret with a new line.
Some report templates, like the Page List templates, do not have a Replace multi-line character(^) with space option.
This article demonstrates how to replace the caret character by adding a script to the report template. With the script, the caret character can be replaced with a space, which removes it like the Replace multi-line character(^) with space BOM report option, or with a line break.
The concept can be applied to other reports: the Replace instruction in the script can be used to remove or replace other characters or entire character strings.
using System.Data;
string ds = "", pg = "", pgdesc1 = "", pgdesc2 = ""; ds = (string)GetCurrentColumnValue("DrawingSet"); pg = (string)GetCurrentColumnValue("Page"); DataSet dataSet1 = eCTReportTemplate1.DataSource as DataSet; DataRow[] dr = dataSet1.Tables["Page Fields"].Select("DrawingSet='"+ds+"' and Page='"+pg+"'"); pgdesc1 = dr[0]["Description 001"].ToString(); pgdesc1 = pgdesc1.Replace("^", " "); (sender as XRLabel).Text = pgdesc1;
string ds = "", pg = "", pgdesc1 = "", pgdesc2 = ""; ds = (string)GetCurrentColumnValue("DrawingSet"); pg = (string)GetCurrentColumnValue("Page"); DataSet dataSet1 = eCTReportTemplate1.DataSource as DataSet; DataRow[] dr = dataSet1.Tables["Page Fields"].Select("DrawingSet='"+ds+"' and Page='"+pg+"'"); pgdesc1 = dr[0]["Description 001"].ToString(); pgdesc1 = pgdesc1.Replace("^", "\r\n"); // for this line to work, Multiline cell property must be Yes (sender as XRLabel).Text = pgdesc1;
using System.Data; private void xrTableCell20_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { string ds = "", pg = "", pgdesc1 = "", pgdesc2 = ""; ds = (string)GetCurrentColumnValue("DrawingSet"); pg = (string)GetCurrentColumnValue("Page"); DataSet dataSet1 = eCTReportTemplate1.DataSource as DataSet; DataRow[] dr = dataSet1.Tables["Page Fields"].Select("DrawingSet='"+ds+"' and Page='"+pg+"'"); pgdesc1 = dr[0]["Description 001"].ToString(); pgdesc1 = pgdesc1.Replace("^", " "); (sender as XRLabel).Text = pgdesc1; }
To replace the caret character with a space
To insert a new line in place of the caret character
string descr1 = ""; if (GetCurrentColumnValue("Detailed_Description1") != DBNull.Value) { descr1 = (string)GetCurrentColumnValue("Detailed_Description1"); descr1 = descr1.Replace("^", "\r\n"); } (sender as XRLabel).Text = descr1;