我想使用Excel工作表公式处理百分比标记以计算CGPA。它在Excel中可以正常运行,但是当我重写它以使用它时,Crystal Reports却无法正常运行。例如,当@Percentage为77时,它会显示3.40 GPA,但应该给出3.50(准确)。
Excel公式,其中J18是每个学生的分数:
<send-request mode="new" response-variable-name="putStorageRequest" timeout="5" ignore-error="true">
<set-url>@((string)context.Variables["blobUrl"])</set-url>
<set-method>PUT</set-method>
<set-header name="x-ms-date" exists-action="override">
<value>@((string) context.Variables["date"] )</value>
</set-header>
<set-header name="x-ms-version" exists-action="override">
<value>@((string) context.Variables["version"] )</value>
</set-header>
<set-header name="x-ms-blob-type" exists-action="override">
<value>BlockBlob</value>
</set-header>
<set-header name="Content-Type" exists-action="override">
<value>application/zip</value>
</set-header>
<set-header name="Authorization" exists-action="override">
<value>@{
string body = context.Request.Body.As<string>(preserveContent: true);
string contentType = "application/zip";
var base64String = (string)context.Variables.GetValueOrDefault<JObject>("body")["data"]) ;
var bytes = Convert.FromBase64String(base64String);
var ascii = Encoding.ASCII.GetString(bytes)
var contentLength = ascii.Length;
var hmacSha256 = new System.Security.Cryptography.HMACSHA256 { Key = Convert.FromBase64String(context.Variables.GetValueOrDefault<string>("storageKey")) };
var payLoad = string.Format("{0}\n\n\n{1}\n\n{2}\n\n\n\n\n\n\nx-ms-blob-type:BlockBlob\nx-ms-date:{3}\nx-ms-version:{4}\n{5}",
"PUT",
contentLength,
contentType,
context.Variables["date"],
context.Variables["version"],
"/" + context.Variables.GetValueOrDefault<string>("storageAccountName") + context.Variables.GetValueOrDefault<string>("resource"));
return "SharedKey "+ context.Variables.GetValueOrDefault<string>("storageAccountName") + ":" + Convert.ToBase64String(hmacSha256.ComputeHash(Encoding.UTF8.GetBytes(payLoad)));
}</value>
</set-header>
<set-body>@{
var base64String = (string)context.Variables.GetValueOrDefault<JObject>("body")["data"]) ;
var bytes = Convert.FromBase64String(base64String);
var ascii = Encoding.ASCII.GetString(bytes);
return ascii;
}</set-body>
</send-request>
与Crystal Reports相同的公式@Percentage是可以正常运行的Percentage Calc公式:
IF(H12>=85,"4.00",IF(H12>=83,"3.90",IF(H12>=82,"3.80",IF(H12>=80,"3.70",IF(H12>=79,"3.60",IF(H12>=77,"3.50",IF(H12>=76,"3.40",IF(H12>=74,"3.30",IF(H12>=73,"3.20",IF(H12>=71,"3.10",IF(H12>=70,"3.00",IF(H12>=69,"2.90",IF(H12>=68,"2.80",IF(H12>=67,"2.70",IF(H12>=66,"2.60",IF(H12>=65,"2.50",IF(H12>=64,"2.40",IF(H12>=63,"2.30",IF(H12>=62,"2.20",IF(H12>=61,"2.10",IF(H12>=60,"2.00",IF(H12>=59,"1.90",IF(H12>=58,"1.80",IF(H12>=57,"1.70",IF(H12>=56,"1.60",IF(H12>=55,"1.50",IF(H12>=54,"1.40",IF(H12>=53,"1.30",IF(H12>=52,"1.20",IF(H12>=51,"1.10",IF(H12>=50,"1.00",IF(H12<50,"0.00",))))))))))))))))))))))))))))))))