You've been using Eclipse Birt for some time, the function of Birt is still more satisfied, the basic can meet the needs of the work, of course, there are some unsatisfactory places, such as Birt longer data in the line of the problem, the author used the process found that the Birt automatic line-wrapping function seems to change only once line, When the next line of text is still longer, it will not change. And there seems to be a problem with the critical choice of line-wrapping, for example, when the combination of Chinese and English is usually in the Chinese and English at the junction of the line instead of the length of the line, such as: "The People's Republic of People's Republic of China" Change lines to become
"People's Republic of China
The format of the People ' s Republic of "is uneven and very uncomfortable." Fortunately Birt Support JS script, you can use the script to achieve their own needs, and personally feel that this is Birt strong place. Since no other reporting tools have been used, Birt is sufficient to meet the day-to-day needs of the work.
Here is a description of the script, there are two ways:
First, write the script in the OnRender event, select the column to be wrapped, switch to the Script page, select the OnRender event, and enter the following script
JS code var name = This.getvalue (); Name = Name.tostring (); var interval = 35;//Specifies the condition of the line break, and when the character exceeds this number, the appropriate length can be specified by the width of the column var n = name.length ()/interval|0; var re = name.length ()% interval; var rslt = ""; for (var i=0 i<n; i++) {var subs = Name.substr (I*interval,interval); Rslt + = (subs + "\ n"); } if (re > 0) {rslt + = Name.substr (n*interval,re); } this.setdisplayvalue (RSLT);
Second, using the text control, the text control supports dynamic expressions, which is useful for our script
JS code <value-of format= "HTML" >// Using HTML format, you can use <BR> line breaks var name = row["M_name"]; var interval = 35;//Specifies the condition of the line break, changing one line when the character exceeds this number var n = name.length / interval | 0; var re = name.length % interval; var rslt = ""; for (var i=0; i<n; i++ ) { var subs = name.substr (i*interval , interval); rslt += ( subs + "<BR>"); } if (re > 0) {   rslt += name.substr (N*interval,re); } this.value = rslt; </ value-of>
Summary: In fact, the two methods are basically the same, except for some specific details, such as in the text expression to find the length of the string is a string variable, and in the OnRender event is a variable length () method; The text is assigned to the This.value property in the text expression, and the This.setdisplayvalue () method is used in the OnRender event, and there are a lot of small differences in other places that you can compare yourself with.
Another problem is because the width of the Chinese character and the West character and the width of the numbers are different, so the number of characters to change the line is not very accurate, expect friends to provide a better solution ...
Reproduced from: http://3ccoder.iteye.com/blog/585716