In the process of developing Crystal Reports, I found that text and lines are often misplaced.
The problem is: there are some old-fashioned reports with underscores in the text, but it cannot be solved by setting the font to the underline font, because if this field is blank, use the underline font, then there is a blank space. the actual requirement is that the line is required no matter whether the field is empty or not.
Therefore, we can only draw lines to solve this problem.
This is really a cumbersome process. it is very difficult to match each line and text exactly. and I found that even if you have spent a lot of time previewing the report in the editor, if the lines and words work well together,
If it is displayed on the page, it is messy (it is often because the lines and text overlap, printing also overlap ).
The report editor I used is crystal reporter for WebLogic Workshop 10.0.0.533.
The support for Java in Crystal Reports must indeed be improved.
However, is there any way to fix this crystal report bug?
The solution is as follows:
1: Assign the field to be displayed to formula field;
2: If this field is blank, the formula field fills in spaces according to the specified length. In this way, the underline can also be displayed when the field is empty.
3: if the number of words in a field is less than the required length, fill space in field a to the specified length.
4. Special Handling for line breaks: remove the line breaks, mark them, and fill in spaces until the line is filled with a whole line. Then, add them to the remaining strings.
It should be noted that the string length obtained by using the Len function of the crystal is incorrect. It regards English and numbers as a length, and Chinese characters as a length. the actual situation is that the placeholder length of Chinese characters is twice that of English and numbers.
Therefore, we need to re-write a function to evaluate the actual length of the string (the Unicode code is 127 and the boundary and halfwidth ):
(Use the crystal report basic script)
''''' Character length Function
Function mylen (word as string)
Dim temp
If ASCW (Word)> 127 then
Temp = 2
Else
Temp = 1
End if
Mylen = temp
End Function
''''' String Length Function
Function mystrlen (STR as string)
Dim I
Dim strlen
Strlen = 0
For I = 1 to Len (STR)
If (ASCW (mid (STR, I, 1) <> 13 and ASCW (mid (STR, I, 1) <> 10) then
Strlen = strlen + mylen (mid (STR, I, 1 ))
End if
Next I
Mystrlen = strlen
End Function
'''''
'Automatic newline fill empty function. Special processing is required for a line with a newline: You need to mark the place where the newline is wrapped, and then fill in spaces until the line is filled with a whole line.
'Str ----- operation string
'Wordnum -- number of characters in each row
Function autochangeline (STR as string, wordnum as number)
Dim tempstr
Dim start 'specifies the starting position of the truncated character.
Dim strlen' truncated character Length
Dim addspacenum 'fill space count
Dim I
Dim J
Start = 1
Tempstr = ""
Addspacenum = 0
For I = 1 to Len (STR)
If ASCW (mid (STR, I, 1) = 10 then
Tempstr = tempstr + mid (STR, start, I-START)
If ASCW (mid (STR, I + 1, 1) = 13 or ASCW (mid (STR, I + 1, 1) = 10 then
I = I + 1
Else
Start = I + 1
End if
'Fill Space
If remainder (mystrlen (tempstr), wordnum) <> 0 then
'Addspacenum = wordnum-remainder (mystrlen (tempstr), wordnum)
Addspacenum= 200
For j = 1 to addspacenum
Tempstr = tempstr + ""
Next J
End if
Tempstr = tempstr + CHR (10)
End if
Next I
'The processing of the last line if there is no line break
If start <Len (STR) then
Tempstr = tempstr + mid (STR, start)
If remainder (mystrlen (tempstr), wordnum) <> 0 then
'Addspacenum = wordnum-remainder (mystrlen (tempstr), wordnum)
Addspacenum= 200
For j = 1 to addspacenum
Tempstr = tempstr + ""
Next J
End if
Start = Len (STR)
End if
Autochangeline = tempstr
End Function
This is the case when using:
For example, to display {lp_xlgzp1.aqcs}, you can define a formula field:
Formula = autochangeline ({lp_xlgzp1.aqcs}, 180) 'each line cannot exceed 180 characters
Drag A to the report and adjust the width to 180. The effect is displayed.
If this field does not contain many characters and you need to add a horizontal line until the bottom of the report, you can add a formula field space:
Dim I
Dim Str
STR = ""
For I = 101 to 4000.
STR = STR + ""
If remainder (I, 100) = 0 then
STR = STR + CHR (10)
End if
Next I
Formula = Str
Put space under a and adjust the sentence "for I = 101 to 4000" as needed. the effect of completing the dashboard is also displayed, and you can just fill in any position at the bottom of the report you want to reach.
I would like to archive it here to help those brothers who are worried about calling the crystal report using Java.