This one has left me completely confused. I have a multi text color cell. Most of the data is shared in one way or another so I wanted to use templates to do most of work. To do that I sought to pass the text color as a parameter to the template. A super simple example:
<xsl:variable name="textColor">
<xsl:choose>
<xsl:when test="$cellColor = 's73'">
<xsl:text>#FFFFFF</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>#000000</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="detailLines">
<xsl:with-param name="textColor" select="$textColor"/>
</xsl:call-template>
<xsl:template name="detailLines">
<xsl:param name="textColor"/>
<!-- Start new line -->
<xsl:text disable-output-escaping="yes">&#10;</xsl:text>
<!-- Bunch of stuff after this -->
<Font html:Color="{$textColor}">
<xsl:text>[</xsl:text>
</Font>
Usually I have no issues out of this, but I was floored when the text color didn't seem to pass. However, when I debug the text color is passing. Further investigation showed that the XML created has the text color as well, but Excel does not display it, but instead defaults to black.
I've got the Excel namespaces in their usual location and even attempting to move them around doesn't help resolve the issue.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
<xsl:output method="xml" encoding="UTF-8"/>
Any ideas would be great! I've not had an issue quite like this where the variable is acting as expected, but Excel is not.
EDIT TO ADD ADDITIONAL INFORMATION:
I've found a difference, but I'm not sure how to interpret it.
<Font html:Color="#FFFFFF">Two Box</Font>
<Font html:Color="#FFFFFF">]</Font>
<Font html:Color="#FFFFFF" xmlns="urn:schemas-microsoft-com:office:spreadsheet">[</Font>
The first two lines are from code that does not enter the detailLines template and so it calls the cellColor variable directly. The last line is from the template where the variable is passed. The namespace seems to be causing my issue, but I can't understand 1) why it is there, and 2) how to make it go away.
EDIT - Addressing cellColor comment
I cannot put the actual code here for multiple reasons, but the cellColor variable is calculated just prior to the textColor. At it's most redacted it is:
<xsl:variable name="cellColor">
<xsl:choose>
<xsl:when test="A">
<xsl:text>s216</xsl:text>
</xsl:when>
<xsl:when test="B'">
<xsl:text>s73</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>s210</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
A cell with different colored letters in is looks like this in spreadsheetML
<Cell> <ss:Data ss:Type="String" xmlns="http://www.w3.org/TR/REC-html40"> <Font html:Color="#000000">tes</Font> <Font html:Color="#9BC2E6">t</Font> </ss:Data> </Cell>
Usually when you want to assign value to a variable in xsl, you should use
<xsl:value-of select=
Change your cellColor variable assignment to :
and the textColor variable to :
About how to make it go away for the xmlns, you can just remove it.
As far as can be determined by myself as well as commenter Peter Vande Weyer there is no way to pass the text color in the manner I am attempting. The issue occurs because the template where this color formatting is located is not the main template so the xslt processor is applying the namespace. This application of the namespace causes Excel to fail as it is not expected in the location that the processor inserts it. The only solution at this juncture is to not use a separate template when handling this text formatting.