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?
 
HyperBPPConnect With a Mentor Commented:
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
 
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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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
 
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
All Courses

From novice to tech pro — start learning today.