在 BIRT 报告中显示空白而不是 0 或 0.0
在某些报告中使用聚合控件时,您希望看到空白字段而不是 0。似乎没有办法自动执行此操作。 有谁有办法可以做到这一点。 请注意,您希望在导出时保留该字段的“0”值,但希望在渲染为 PDF 或 HTML 时显示空白。
When using an aggregate control in some reports you would prefer to see a blank field instead of 0. There does not appear to be a way to do this automatically. Does anyone have a way that this can be done. Note, you want to maintain the '0' value for the field in cases when you export, but you want to show a blank when rendering to PDF or HTML.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅供参考,在使用了一段时间后,我发现使用可见性规则更容易。 一大优点是您可以轻松地为不同的输出格式配置不同的可见性。 因此,对于 PDF,最好使用空白,但对于 Excel,您可能需要 0 值。
Just an FYI, after working with this for a while longer, I have found that it is just easier to use Visibility rules. The one big advantage is that you can easily configure different visibility for different output formats. So for PDF it may be best to use blanks, but for Excel you may want the 0 values.
有多种方法可以解决这个问题。 两个主要方法是使用可见性规则或突出显示来创建条件格式。 可见性特别有吸引力,因为很容易仅将格式规则应用于特定类型的输出(例如 HTML)。
对于这种特殊情况,这些方法存在两个问题。 首先,我想要一个无需指定文本颜色的通用解决方案。 换句话说,当条件为真(值为 0)时,我希望文本颜色与背景颜色匹配。 这样,如果有人更改控件的背景颜色,代码仍然有效。
另一个问题是,在这种情况下,我使用不支持值查找的动态列绑定。
我创建的解决方案是添加一个名为 hideMe 的 JavaScript 函数,如下所示。
一旦这个函数被添加到报告中(在我的例子中是一个包含的 javascript 文件),我只需从控件的 OnCreate 方法中调用它。
这也可以使用 Java 事件处理程序来完成,但这种方法似乎更容易。
There are a number of ways to solve this. The two primary are to use either visibility rules or highlights to create conditional formatting. The visibility is particularly attractive since it is easy to only apply the format rules to particular types of output (e.g. HTML).
For this particular case, there are two problems with these approaches. First, I want a general solutions where I don't have to specify the text color. In other words, when the condition is true (value of 0) then I want my text color to match the background color. In that way if someone changes the backgroundColor for the control, the code still works.
The other issue is that in this case I am using dynamic column binding which does not support value lookup.
The solution that I created was to add a JavaScript function called hideMe as shown below.
Once this function has been added to the report (in my case an included javascript file) I just call it from the OnCreate method of the control.
This can also be done using Java Event Handlers but this method seems to be easier.