简体   繁体   English

在 Adobe Document Generation API 中格式化计算值

[英]Formatting calculated values in Adobe Document Generation API

In the template language docs for Adobe Document Generation , mathematical expressions can be done using tags like below...Adobe Document Generation的模板语言文档中,可以使用如下标签来完成数学表达式...

{{expr(revenue - expenditure)}}

This works and outputs a number, but is there any way to apply formatting to the number, for example, $50,000.00 where the calculated value is just 50000?这可以工作并输出一个数字,但有没有办法对数字应用格式,例如,50,000.00 美元,计算值仅为 50000?

Remember that doc gen uses JSONata ( https://docs.jsonata.org/overview.html ) for it's template parsing.请记住,doc gen 使用 JSONata ( https://docs.jsonata.org/overview.html ) 进行模板解析。 As I've learned and played with docgen, the JSONata docs have been really helpful.正如我学习和使用 docgen 一样,JSONata 文档真的很有帮助。 For this particular example, there's a function built in documented under Numeric functions - $formatNumber .对于这个特定的示例,有一个 function 内置记录在数字函数- $formatNumber下。 At minimum it takes a number input and a mask.至少它需要一个数字输入和一个掩码。 So to format it as you would want, use:因此,要根据需要对其进行格式化,请使用:

{{$formatNumber(revenue-expenditure, '#,###.00')}}

Notice that you don't use expr above, just the function.请注意,您没有使用上面的expr ,而只是 function。

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

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