carriage return in xslt cell

<Row> <Cell>
                  <Data ss:Type="String" >
                      Line1
                      Line2
                   </Data>
                 
                </Cell>
</Row>
I want to insert a carriage return between line 1  & line2.

I tried all possible ways of using asscii characters and <PRE>. Nothing worked.
ammu1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HyperBPPCommented:
You could use:
<xsl:text>
</xsl:text>

or

<xsl:text>&#10;</xsl:text> <!-- newline character -->

or

<xsl:text>&#13;</xsl:text> <!-- carriage return character -->
0
kmartin7Commented:
Is this specific to generating Excel?
0
kmartin7Commented:
If it is specific to Excel, then try something like the following:

<Cell ss:StyleID="s21">
	<Data ss:Type="String">
		<xsl:for-each select="xpath_statement_here">
			<xsl:value-of select="."/>
			<xsl:if test="not(position() = last())">
				<xsl:text disable-output-escaping="yes">&amp;#10;</xsl:text>
			</xsl:if>
		</xsl:for-each>
	</Data>
</Cell>

Open in new window

0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

kmartin7Commented:
Make sure you explicitly make the "&" in the xsl:text as &amp;
0
ammu1Author Commented:
None of the above solutions worked.
I tried again. still no luck.
This will generate an excel file.
The excel cell should have break in one cell between data.
0
ammu1Author Commented:
tried explicitly but didn't work.
0
kmartin7Commented:
What processor are you using? can you post some sample XML and your XSLT?
0
ammu1Author Commented:
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    xmlns:user="urn:my-scripts"
        xmlns:o="urn:schemas-microsoft-com:office:office"
        xmlns:x="urn:schemas-microsoft-com:office:excel"
        xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">


  <xsl:template match="Report">

    <Workbook 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">
<Worksheet ss:Name="Transportation Benefits Report">
          <Table>
 <xsl:for-each select="Transportation">
              <Row>
 <Cell>
                  <Data ss:Type="String" >
                      Line1<xsl:text>
</xsl:text>
                    Line2
                </Data>
                </Cell>
</Row>
</Row>
            </xsl:for-each>
           
       </Table>
      </Worksheet>
    </Workbook>

  </xsl:template>

</xsl:stylesheet>
 XmlDataDocument xmlDataDocument = new XmlDataDocument(dataset);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xmlDataDocument.OuterXml);

 XslCompiledTransform xslTran = new XslCompiledTransform();
                    xslTran.Load(HttpContext.Current.Server.MapPath(@"n.xslt"));
xslTran.Transform(xmlDoc, null, HttpContext.Current.Response.OutputStream);

                    HttpContext.Current.Response.End();

0
kmartin7Commented:
Replace:
<Data ss:Type="String" >
                      Line1<xsl:text>
</xsl:text>
                    Line2
                </Data>

With:
<Data ss:Type="String">Line1<xsl:text disable-output-escaping="yes">&amp;#10;</xsl:text>Line2</Data>

Tested with MSXML and Saxon, and works beautifully.
0
ammu1Author Commented:
Just copy pasted what you gave me. for me its not working.  End result is in excel2007.

Please see the attached excel.


sample.xlsx
0
HyperBPPCommented:
If you add a style to the <styles> section, and then tell the <cell> to use that style, then it pays attention to the &#10;
I saved your xslt as xml.  do a search for s62 to see where I inserted the new data.
  <Style ss:ID="s62">
   <Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
  </Style>
    <Cell ss:StyleID="s62"><Data ss:Type="String">Line1&#10;Line2</Data></Cell>

Open in new window

sample.xml
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.