Link to home
Start Free TrialLog in
Avatar of EngSiong
EngSiong

asked on

Need to prevent numeric data from to default to print as number and print as text

I am using a software called Navision 5.0 which can export data to Excel. The file that is activated is an XSLT file. The problem is that when the data is exported to Excel, all the numeric data that have zeros infront (Example Item No.: 01000) automatically change to 1000.

I do not have any experience with XML or XSLT but I was wondering if there is a way for me to change the logic so that all the numeric data are converted to text.  
<Style ss:ID="TextBoxNumber">
				<Alignment ss:Horizontal="Right" ss:Vertical="Bottom"/>
				<Font ss:FontName="Verdana" x:Family="Swiss"/>
				<NumberFormat ss:Format="Standard"/>
			</Style>
 
....
 
 
<xsl:attribute name="ss:StyleID">TextBoxNumber</xsl:attribute>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of BobSiemens
BobSiemens

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of EngSiong
EngSiong

ASKER

I am grateful for your suggestion. However, I do need to point out that there is only one generic stylesheet for Excel so there is no way for me target a column or even columns specifically. This is because the program will print the all the columns of data in Excel via the stylesheet. Moreover, all forms that can print the report will launch the same stylesheet preventing me from defaulting the format in the stylesheet. The only place I want to target is the data which I have narrowed the problem down to the variable TextBoxNumber.  

My snippet are not related because I am only targeting the code that is related to the variable TextBoxNumber.

Any other suggestions while I try to enter the quote marks around the variable?
Have some breakthrough on the XSLT code. I manage to change the code to NumberFormat ss:Format="@" The logic should work but I suspect the numbering logic is  
Code that I changed but does not affect the output.
			<Style ss:ID="TextBoxNumber">
				<Alignment ss:Horizontal="Right" ss:Vertical="Bottom" />
				<Font ss:FontName="Verdana" x:Family="Swiss"/>
				<NumberFormat ss:Format="@"/>
			</Style>
 
----
Code that I suspect is affecting the output 
			<Data>
				<xsl:choose>
					<xsl:when test="string(number(translate(@value,',.','11')))!='NaN'">
						<xsl:choose>
							<xsl:when test="contains(@value,'..')">
								<xsl:attribute name="ss:Type">String</xsl:attribute>
								<xsl:value-of select="@value"/>
							</xsl:when>
							<xsl:when test="@value = translate(@value,',.','')">
								<xsl:attribute name="ss:Type">Number</xsl:attribute>
								<xsl:value-of select="@value"/>
							</xsl:when>
              <xsl:when test="$DecimalSeparator = '.'">
                <xsl:attribute name="ss:Type">Number</xsl:attribute>
                <xsl:value-of select="translate(@value,',','')"/>
              </xsl:when>
              <xsl:when test="$DecimalSeparator = ','">
                <xsl:attribute name="ss:Type">Number</xsl:attribute>
                <xsl:value-of select="translate(translate(@value,'.',''),',','.')"/>
              </xsl:when>
              <xsl:otherwise>
								<xsl:attribute name="ss:Type">Number</xsl:attribute>
								<xsl:value-of select="translate(translate(@value,'.',''),',','.')"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:when>
					<xsl:otherwise>
						<xsl:attribute name="ss:Type">String</xsl:attribute>
						<xsl:value-of select="@value"/>
					</xsl:otherwise>
				</xsl:choose>
			</Data>

Open in new window

Sorry about the incomplete message.

What I meant was
Have some breakthrough on the XSLT code. I manage to change the code to NumberFormat ss:Format="@" The logic should work but I suspect the numbering logic is affected further down the code.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial