如何在另一个文本字段中使用文本字段表达式的结果?
我有以下文本字段表达式:
( $P{currency}.equals( "EUR" ) )
? $F{documentPeriodsRate}
: $P{currency}.equals( "USD" ) && $F{documentHeadDocClass}.equals( "1" )
? $F{documentPeriodsRate} / $F{foreignCurrencyUSDBid}
: $P{currency}.equals( "USD" ) && $F{documentHeadDocClass}.equals( "2" )
? $F{documentPeriodsRate} / $F{foreignCurrencyUSDAsk}
: $P{currency}.equals( "GBP" ) && $F{documentHeadDocClass}.equals( "1" )
? $F{documentPeriodsRate} / $F{foreignCurrencyGBPBid}
: $P{currency}.equals( "GBP" ) && $F{documentHeadDocClass}.equals( "2" )
? $F{documentPeriodsRate} / $F{foreignCurrencyGBPAsk}
: $P{currency}.equals( "CHF" ) && $F{documentHeadDocClass}.equals( "1" )
? $F{documentPeriodsRate} / $F{foreignCurrencyCHFBid}
: $P{currency}.equals( "CHF" ) && $F{documentHeadDocClass}.equals( "2" )
? $F{documentPeriodsRate} / $F{foreignCurrencyCHFAsk}
: $P{currency}.equals( "YEN" ) && $F{documentHeadDocClass}.equals( "1" )
? $F{documentPeriodsRate} / $F{foreignCurrencyJPYBid}
: $P{currency}.equals( "YEN" ) && $F{documentHeadDocClass}.equals( "2" )
? $F{documentPeriodsRate} / $F{foreignCurrencyJPYAsk}
: ""
我需要上面表达式的结果来计算另一个文本字段。我试图将上面的表达式放在变量$V{euroCalc}
中,并用变量$V{euroCalc}
替换上面的textfield表达式,但后来我出现了以下错误。:
Error filling print... Error evaluating expression :
Source text : $V{euroCalc}
Setting up the file resolver...
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :
Source text : $V{euroCalc}
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:203)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:591)
at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:559)
at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:884)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluateText(JRFillTextField.java:421)
at net.sf.jasperreports.engine.fill.JRFillTextField.evaluate(JRFillTextField.java:406)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:457)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2037)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:771)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:281)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:144)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:909)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:822)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:61)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:276)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:745)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:891)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997)
Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
at boss_charterfaktura_document_list_interval_positions_1392719953257_176604.evaluate(boss_charterfaktura_document_list_interval_positions_1392719953257_176604:307)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:190) ... 20 more
Print not filled. Try to use an EmptyDataSource...
将表达式值用于其他计算的正确方法是什么?
答案 0 :(得分:2)
问题是变量类型String
。
Caused by: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
如果设置为Double
,则可以正常工作。