简体   繁体   English

SSRS报表构建器LENGTH表达式和大小特定字段

[英]SSRS Report builder LENGTH expression & size specific field

I'm trying to build a bank file using SSRS report builder (3.0). 我正在尝试使用SSRS报表生成器(3.0)构建银行文件。 I'm running into two issues: 我遇到两个问题:

  1. I'm trying to get a length expression to work on a check number field but LEN(Field) doesn't work (returns 4 as the value regardless of the actual length of the field). 我试图获取一个长度表达式以在支票号码字段上工作,但是LEN(Field)不起作用(无论字段的实际长度如何,都将返回4作为值)。

And LENGTH(Field) gives me an error: LENGTH(Field)给我一个错误:

The Value expression for the textrun 'Textbox15.Paragraphs[0]. textrun'Textbox15.Paragraphs [0]的值表达式。 TextRuns[0\\' contains an error: [BC30451] Name 'LENGTH' is not declared* TextRuns [0 \\'包含错误:[BC30451]未声明名称'LENGTH'*

  1. The only reason why I'm even trying to get #1 to work is because I need to have one of the fields on the bank file have a constant length. 我什至试图使#1起作用的唯一原因是,我需要使bank文件中的字段之一具有恒定的长度。 Regardless of the check number, I need to make sure this field is always at 14 characters with leading zeros. 无论支票号码如何,我都需要确保该字段始终为14个字符,前导零。 I thought the best way to do this is to do a switch statement and add the number of appropriate zeros in depending on the size of the check number field. 我认为最好的方法是执行switch语句,并根据支票号码字段的大小添加适当的零的数量。

Thanks for the help. 谢谢您的帮助。

Edit: using a SQL server DB 编辑:使用SQL Server数据库

I don't know on which database you are working if you are using sql server then try LEN function and LENGHT in oracle. 如果您使用的是SQL Server,我不知道您在哪个数据库上工作,然后在oracle中尝试LEN函数和LENGHT。

I think you first convert it into integer if it's character and then try len function. 我认为您首先将其转换为整数(如果是字符),然后尝试len函数。

For the length issue: 对于长度问题:

There are two ways to get string length 有两种获取字符串长度的方法

Using the LEN function 使用LEN功能

= LEN(Fields!myfield.Value)

Using the length property 使用length属性

= Fields!myfield.Value.Length

If your field is not a string, try converting first by using the Cstr function 如果您的字段不是字符串,请尝试首先使用Cstr函数进行转换

= LEN( Cstr(Fields!myfield.Value) )
= Cstr(Fields!myfield.Value).Length

For the formatting issue: 对于格式问题:

For numeric fields set the cell format expression to have as many zeros as required eg. 对于数字字段,将单元格格式表达式设置为具有所需的多个零,例如。 for 14 digit numbers 14位数字

= "00000000000000"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM