I'm using the .Net framework's XslCompiledTransform class as the XSLT processor (in other words Xslt 1.0).
My requirement is that I want to convert an XML file to an Excel file (xls file) using XSLT 1.0 and .Net [4.0].
For simplicity and since this is just test code, I'm just considering some simple hard-coding on my Xsl file.
Specifically, my two questions are:
I've tried a bunch of things, yet I can't see my Excel sheet's worksheet named to "wAbc" which is what I'm trying to name it. I see the worksheet name as my file name. Additional worksheets are not generated as well. Below is my XSL file
Additionally, since this is test code, I can't see the data outputted on different rows unless I use HTML tags . What I see is:
AbcNext
line instead of
Abc
Nextline
So what am I doing wrong? Thank you in advance for your time and help.
acorneronthe...
Member
14 Points
7 Posts
Xslt 1.0 XML to excel transformation issue
Apr 25, 2012 06:40 PM|LINK
I'm using the .Net framework's XslCompiledTransform class as the XSLT processor (in other words Xslt 1.0).
My requirement is that I want to convert an XML file to an Excel file (xls file) using XSLT 1.0 and .Net [4.0].
For simplicity and since this is just test code, I'm just considering some simple hard-coding on my Xsl file.
Specifically, my two questions are:
line instead of
So what am I doing wrong? Thank you in advance for your time and help.
I set the content type for my file response as
Here is my test Xsl file:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" 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"> <xsl:template match="/"> <xsl:processing-instruction name="mso-application">progid='Excel.Sheet'</xsl:processing-instruction> <Workbook> <Worksheet ss:Name="wAbc"> <Table ss:ExpandedColumnCount="2" x:FullColumns="1" x:FullRows="1" ss:DefaultRowHeight="15"> <Column ss:AutoFitWidth="20" ss:AutoWidth="65"></Column> <Row> <Cell> <Data ss:Type="String">Abc</Data> </Cell> </Row> <Row> <Cell> <Data ss:Type="String">Next line</Data> </Cell> </Row> </Table> <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel"> <PageSetup> <Header x:Margin="0.3"/> <Footer x:Margin="0.3"/> <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/> </PageSetup> </WorksheetOptions> </Worksheet> </Workbook> </xsl:template> </xsl:stylesheet>TimoYang
Contributor
3732 Points
1275 Posts
Re: Xslt 1.0 XML to excel transformation issue
Apr 27, 2012 02:12 AM|LINK
Your answer seems right……Anything wrong? You want to make them become two lines???