mysticfall / pivot4j

Pivot4J provides a common API for OLAP servers which can be used to build an analytical service frontend with pivot style GUI.
Other
128 stars 101 forks source link

Set cell property for specific column #204

Closed gascani closed 7 years ago

gascani commented 7 years ago

I use the cell property to set background color to red if value is greater then 10. Es (<#if cell?? && cell.value > 10>#ff0000</#if>).

Is it possible to set cell property for a single specific column? Furthermore there is some option to set property for every report of a specific cube?

Thanks, Giorgio

mysticfall commented 7 years ago

Definitely you can, but '<' and '>' signs need to be escaped as '<' and '>' respectively, as they would be recognized as tag symbols.

Writing a condition which tests for a specific column is possible, though it might be a bit cumbersome especially if you need to put it in the cell area.

If it's in the headers, you can simply reference member or hierarchy context variables, and compare their uniqueName or caption properties to a specific value.

But if it's in the cell area, you need to reference rowPosition or columnPosition first, then navigate down to their members, like for example:

<#if rowPosition?? && rowPosition.members[0]?? && rowPosition.members[0].uniqueName == '[Product].[Food]'>

For now, there's no such feature which would make such properties to be applied across reports. But as always, you can just extend the relevant API to implement a similar functionality, as property expressions are just some texts which can be easily stored to and loaded from an external data store, like a database.

Please let me know if you need further help. Thanks!

gascani commented 7 years ago

Thank you, i discovered that I can use also something like this:

` <#if cell?? && cell.value??> <#if columnPosition.members.contains(memberUtils.lookupMember("[Measures].[MyMeasure]"))> <#if cell.value gt 20 >

ff0000

    <#else>
        #00ff00
    </#if>
</#if>

</#if> `

To apply cell formatting property to all report I found it's possibile directly on pivot4j-config.xml with the option even if is not a clean solution because this affect all report whitout the possibility to change properties later.

Es: `

<#if cell?? && cell.value??> <#if columnPosition.members.contains(memberUtils.lookupMember("[Measures].[MyMeasure]"))> <#if cell.value gt 20 > #ff0000 <#else> #00ff00 </#if> </#if> </#if>

`

Thanks again, Giorgio