水晶报表中除去某数字类型字段小数点后多余的零 及 在小数点前零不显示的解决方案

 水晶报表中除去某数字类型字段小数点后多余的零

Local StringVar strTemp := ToText({Command.WorkLoad}, 2,"");
Local NumberVar i;
Local StringVar str := "";
Local NumberVar strLen := Length (strTemp);
For i := strLen To 1 Step -1 Do
(
   If strTemp[i] = "." Then
   (  //Integer,we should delete the point
      str := Left(strTemp, i-1);
      Exit For
   )
 
   Else If strTemp[i]  <> "0" then
   (
      str := Left(strTemp, i);
      Exit For
   )
);
//Leading Zero
If str[1] = "." Then
(
str := "0"+str;
);
Str

 

 

 

 


  在小数点前零不显示的解决方案

 

if right(ToText ({Command.WorkLoad},2,"" ),2)= ".00"

                 then cstr({Command.WorkLoad},2,"")//显示小数位数为0

        else if {Command.WorkLoad}<1 and {Command.WorkLoad}>0

                 then "0"+cstr({Command.WorkLoad},2,"")

        else cstr({Command.WorkLoad},2,"")//显示小数位数为2

 

 


 

你可能感兴趣的:(解决方案)