Solved

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

Posted on 2008-06-24
5
522 Views
Last Modified: 2013-11-18
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

0
Comment
Question by:EngSiong
  • 3
5 Comments
 
LVL 10

Accepted Solution

by:
BobSiemens earned 300 total points
ID: 21857480
The problem is that excel thinks that that 01000 is a number.  In order to pevent that from happening, the exported data needs to look like text.  If you put double quotes around it, Excel will decide it's a string and won't delete the leading zero and won't display the quotes.

This is a sample of the XSL code that would do that:

&quot;<xsl:value-of select="PriceCode"/>&quot;

Your snippet doesn't seem to relate.  Your snippet is setting a CSS StyleID attribute.

Also, by the way, you can set the format of Excel cells so they display a fixed number of digits (with leading zeros).  Choose a custom format of 0000 for that column.
0
 
LVL 1

Author Comment

by:EngSiong
ID: 21862614
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?
0
 
LVL 1

Author Comment

by:EngSiong
ID: 21863644
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

0
 
LVL 1

Author Comment

by:EngSiong
ID: 21863647
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.
0
 
LVL 4

Assisted Solution

by:AndersHedegaard
AndersHedegaard earned 200 total points
ID: 21895625
When I look at an xslt definition from a Navision demo database I get the below. Try to set the Type="String" in you xslt file. That could be a solution.

<Cell ss:StyleID="formCaption">
      <Data ss:Type="String">
            <xsl:value-of select="//Object/@caption"/>
      </Data>
</Cell>
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
CRM 2011 Ribbon Workbench vs RibbonDiffXml 44 203
ColdFusion Rereplace 3 62
XML Data Missing in PHP SimpleXML 8 24
Adjust the position 3 13
Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now