B
Bryan Ax
I'm trying to fix a bug in someone else's code. He's got a string saved
in a database such as:
<xsl:variable name="Var1">
<xsl:choose>
<xsl:when test="@SomeAttribute > 1'">
<xsl:value-of select="'Y'"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="'N'"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>
I'm trying to export this value from the database to Excel, and
maintain the carriage returns inside a cell in Excel. I found that in
order to have the xsl appear in the cell, I had to call
Server.HtmlEncode on the value that comes back from the database, but
have not found a means to replace the \r\n that I see in my string
value in C# with a value that Excel will like to create line breaks
inside of the cell.
The code is not working directly with an Excel object, but instead is
filling a result set into a datagrid and then streaming the datagrid to
an excel workbook using:
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = string.Empty;
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new
System.Web.UI.HtmlTextWriter(sw);
dg.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
Any ideas?
Bryan
in a database such as:
<xsl:variable name="Var1">
<xsl:choose>
<xsl:when test="@SomeAttribute > 1'">
<xsl:value-of select="'Y'"/>
</xsl:when>
<xsltherwise>
<xsl:value-of select="'N'"/>
</xsltherwise>
</xsl:choose>
</xsl:variable>
I'm trying to export this value from the database to Excel, and
maintain the carriage returns inside a cell in Excel. I found that in
order to have the xsl appear in the cell, I had to call
Server.HtmlEncode on the value that comes back from the database, but
have not found a means to replace the \r\n that I see in my string
value in C# with a value that Excel will like to create line breaks
inside of the cell.
The code is not working directly with an Excel object, but instead is
filling a result set into a datagrid and then streaming the datagrid to
an excel workbook using:
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = string.Empty;
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htw = new
System.Web.UI.HtmlTextWriter(sw);
dg.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
Any ideas?
Bryan