简体   繁体   English

如何使用Java在Jasper报表中动态隐藏列?

[英]How to dynamically hide a column in jasper report using java?

I am well aware that printwhenexpression is used to hide or show a column . 我很清楚printwhenexpression用于隐藏或显示column But how can I use it from Jave? 但是如何从Jave使用它呢? There is very little documentation of JDesignExpression available. JDesignExpression文档很少。 How can I set a value to false for a JDesignFrame ? 如何将JDesignFrame的值设置为false

Below is the screenshot: 下面是屏幕截图:

在此处输入图片说明

I don't know much how do I set any expression to a StaticText or textfield or designframe . 我不知道如何将任何表达式设置为StaticTexttextfielddesignframe

JRDesignExpression expression = new JRDesignExpression();

        expression.setValueClassName(Object.class.getName());
        expression.setValueClassName(measure.getValueClassName());

Try 尝试

JRDesignTextField textField = new JRDesignTextField();
textField.setPrintWhenExpression(new JRDesignExpression("$V{REPORT_COUNT} < 10"));

Use your specific condition expression instead of $V{REPORT_COUNT} < 10 使用您的特定条件表达式,而不是$ V {REPORT_COUNT} <10

Same settings work for JRDesignFrame too. 同样的设置也适用于JRDesignFrame。

add a condition that may help eg 添加可能有助于例如的条件

JRDesignExpression cond1 =
    OroJasperDesign
        .tool
        .createExpression("$P{docType}
        .equalsIgnoreCase(\"MER\") ? Boolean.TRUE : Boolean.FALSE",Boolean.class);

band.addElement(OroJasperDesign
                    .tool
                    .createTextField(5, 70, pageWidth - 10, 30,
                                     textAlignment, null,
                                     orosoft
                                         .reports
                                         .jasperreports
                                         .OroReportFont
                                         .setFont(12, true, false, true),
                                     OroJasperDesign
                                         .tool
                                         .createExpression("$P{mepRmkInv}",
                                     String.class),cond1));

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

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