Skip to Content

XSLT transformation - change the cell style dynamically

Hi,

I am using XSLT transformation technique for downloading data into formatted excel. I have created the transformation. we have amount field as one of the column in excel. The challenge here is amount format changes depending on currency. for example fro JPY there are no decimal places for EUR decimlas paces are 2. So in a column different cells need to have different format.

in XSLT I have below code for this cell

<Cell ss:StyleID="s63">

<Data ss:Type="Number">

<tt:value ref="TOTAL_VALUE"/>

</Data>

</Cell>

style s63 is

<Style ss:ID="s63">

<Alignment ss:Horizontal="Left" ss:Vertical="Bottom"/>

<NumberFormat ss:Format="#,##0"/>

</Style>

This code works for JPY but not for EUR.

the cell statement executes in a loop over data which comes from ABAP WD program and lets assume that I have a field which says about the number of decimal places that needs to be displayed. Also assume that I have create <Style> coding for different decimal formats ( like one for 0 decimals and one for 2 decimals etc.,). Assuming that I have this information with me in XSLT run time, how can I change the transformation code,so that amounts are displayed correctly?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on May 26, 2016 at 07:23 AM

    Hi,

    I have solved this by switch statement. below is the code. hope this helps others. I am sending a variable from abap program to transformation called CURRDEC and using the value i am using different cell formats

    <tt:switch>

    <tt:s-cond check="CURRDEC=0">

    <Cell ss:StyleID="s63">

    <Data ss:Type="Number">

    <tt:value ref="TOTAL_VALUE"/>

    </Data>

    </Cell>

    </tt:s-cond>

    <tt:s-cond check="CURRDEC=2">

    <Cell ss:StyleID="s64">

    <Data ss:Type="Number">

    <tt:value ref="TOTAL_VALUE"/>

    </Data>

    </Cell>

    </tt:s-cond>

    <tt:s-cond check="CURRDEC=3">

    <Cell ss:StyleID="s65">

    <Data ss:Type="Number">

    <tt:value ref="TOTAL_VALUE"/>

    </Data>

    </Cell>

    </tt:s-cond>

    <tt:s-cond check="CURRDEC=5">

    <Cell ss:StyleID="s66">

    <Data ss:Type="Number">

    <tt:value ref="TOTAL_VALUE"/>

    </Data>

    </Cell>

    </tt:s-cond>

    </tt:switch>

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Sankara

      How would a "switch" and "cond check" be coded within a loop?

      For example, In my transformation I'm looping thru a table that was sent from Abap, like this small sample:

      <tt:loop ref=".DATATAB">

      <Row ss:Height="14" ss:StyleID="s57">

      <Cell ss:StyleID="s64"><Data ss:Type="String"><tt:value ref="MATNR"/></Data></Cell>

      <Cell><Data ss:Type="String"><tt:value ref="QUANT1"/></Data></Cell>

      </Row>

      </tt:loop>

      I would like to assign a different StyleID to the row if I detect a certain value in the line that I'm looping thru. For example, in simple terms:

      If tt:value ref="MATNR" = 'ZZZ' .

      <Row ss:Height="14" ss:StyleID="s57">

      endif.

      If tt:value ref="MATNR" <> 'ZZZ' .

      <Row ss:Height="14" ss:StyleID="s99">

      endif.

      Is that possible?

      Am I being clear?

      Thanks

      Leo

  • Posted on May 25, 2016 at 05:06 PM

    Are you just looking for xsl:if or xsl:choose/xsl:when ? (if currency with 2 places after decimal point, then use the corresponding style, else if 0 place after decimal point, then use the other style)

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.