Product(s): Promis.e, Bentley Substation Version(s): through 10.00.00.232 Environment: N/A Area: Template Management Subarea: Report Template Designer Background The caret character (^) can be entered in various text fields on dialogs in the software to indicate a line break. When displaying the text on the page, a line feed / new line is inserted in place of the caret character. This functionality is not recognized by report templates however, so in [[Run Reports]] many 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 software replace the caret with a new line out-of-the-box. 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. 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, as the Replace instruction in the script can be used to remove or replace other characters or entire character strings. Steps to Accomplish Page List report templates Open a page of a project in which the value for the first page description includes the caret character for at least one page. This will allow the report template to be tested with a good example. Open [[Report Template Designer]] . Select File > Open and open the "Page List - Drawing (inch)" report template. In the Designer view, find the cell on the template that contains the [Page.Fields.Description 001] variable. Refer to the [[Before Print scripts for report templates|BeforePrint script]] article to unbind the variable from the cell and access the Before Print script. Paste the following before the "private void xrTable..." line of the Before Print script. using System.Data; Paste the following within the curly brackets { } of the script to replace the caret with a space: 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; Alternatively, paste the following within the curly brackets { } of the script to insert a line feed in place of the caret: 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; Be sure to select the cell bound to the new script and go to the Property Grid , then set the Multiline property to "Yes". In recent versions, the Multiline property is in the Behavior category. The script should look something like the following when finished: 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; } Select the Preview tab to preview the report. Select File > Save As and save the template to a new name. BOM templates To replace the caret character with a space Open [[Run Reports]] . Select the desired BOM report template. Click the Options button and set the Replace multi-line character(^) with space check box. Preview or Run the report. To insert a new line in place of the caret character Open a page of a project that contains part numbers with carets (^) in their descriptions. Open [[Report Template Designer]] . Select File > Open and open the "Page List - Drawing (inch)" report template. In the Designer view, find the cell on the template that contains the [ Detailed_Description1] variable. Refer to the [[Before Print scripts for report templates|BeforePrint script]] article to unbind the variable from the cell and access the Before Print script. Paste the following within the curly brackets { } of the new script string descr1 = ""; if (GetCurrentColumnValue("Detailed_Description1") != DBNull.Value) { descr1 = (string)GetCurrentColumnValue("Detailed_Description1"); descr1 = descr1.Replace("^", "\r\n"); } (sender as XRLabel).Text = descr1; Be sure to select the cell bound to the new script and go to the Property Grid , then set the Multiline property to "Yes". In recent versions, the Multiline property is in the Behavior category. Select File > Save As and save the template to a new name. Close Report Template Designer. Open [[Run Reports]] . Select the new report template. Click the Options button and clear the Replace multi-line character(^) with space check box. Preview or Run the report. Original Author: Matt_P
↧