And I'd like to get this from the transformation (XSLT) result:
name : Shock
language : Ruby
owner : Brian May
state : New
Date : 31/10/2008 0:00:00
Does anyone know the XSLT to achieve this? I'm using .net in case that matters. I don't have knowledge on XSLT. Can you help me to prepare XSLT to excel.
Does anyone know the XSLT to achieve this? I'm using .net in case that matters. I don't have knowledge on XSLT. Can you help me to prepare XSLT to excel.
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to change your xml file to excel like below format:
Or below format:
Besides, I suggest you could refer to follow link to know how to using xslt format your xml and show in the excel:
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Thanks for prompt reply. Second one is the Correct. If the Project is repeated once then we need to generate in another excel file. Not in another excel sheet.
Thanks for prompt reply. Second one is the Correct. If the Project is repeated once then we need to generate in another excel file. Not in another excel sheet.
As far as I know, xslt couldn't generate two excel file.
In my opinion, one xml file means one file.
We couldn't generate the two excel file.
I suggest you could use C# select the different nodes and load different xml.
Then you could use XslCompiledTransform.Transform method to format the xml by using xslt file.
XmlDocument xdoc = new XmlDocument();
xdoc.Load(@"c:\users\v-xxxx\documents\visual studio 2015\Projects\Error\Error\example.xml");
XmlNodeList nodes = xdoc.SelectNodes("/projects/project");
int i = 0;
foreach (XmlNode node in nodes)
{
i++;
XmlDocument a = new XmlDocument();
a.LoadXml("<?xml version='1.0' encoding='UTF-8'?>" + node.OuterXml);
//XmlDeclaration declaration =a.CreateXmlDeclaration("1.0", "UTF-8", null);
//a.AppendChild(declaration);
XslCompiledTransform xct = new XslCompiledTransform();
xct.Load(@"c:\users\v-xxxx\documents\visual studio 2015\Projects\Error\Error\exap.xslt");
XmlTextWriter writer = new XmlTextWriter(@"c:\users\vxxxx\documents\visual studio 2015\Projects\Error\Error\output" + i + ".xls", null);
writer.WriteProcessingInstruction("xml", "version='1.0'");
xct.Transform(a, null, writer);
writer.Close(); }
Result:
Best Regards,
Brando
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
2 Points
48 Posts
XML to excel (.xls) using XSLT
Nov 05, 2016 03:08 AM|meygnanam|LINK
I have the following XML document:
And I'd like to get this from the transformation (XSLT) result:
Does anyone know the XSLT to achieve this? I'm using .net in case that matters. I don't have knowledge on XSLT. Can you help me to prepare XSLT to excel.
Star
9831 Points
3120 Posts
Re: XML to excel (.xls) using XSLT
Nov 07, 2016 07:57 AM|Brando ZWZ|LINK
Hi meygnanam,
According to your description, I couldn't understand your requirement clearly.
Do you mean you want to change your xml file to excel like below format:
Or below format:
Besides, I suggest you could refer to follow link to know how to using xslt format your xml and show in the excel:
https://blogs.msdn.microsoft.com/brian_jones/2005/06/30/intro-to-excel-xml-part-2-displaying-your-data/
https://blogs.msdn.microsoft.com/brian_jones/2005/06/27/introduction-to-excel-xml-part-1-creating-a-simple-table/
Best Regards,
Brando
Member
2 Points
48 Posts
Re: XML to excel (.xls) using XSLT
Nov 08, 2016 09:55 AM|meygnanam|LINK
Hi,
Thanks for prompt reply. Second one is the Correct. If the Project is repeated once then we need to generate in another excel file. Not in another excel sheet.
Star
9831 Points
3120 Posts
Re: XML to excel (.xls) using XSLT
Nov 10, 2016 11:34 AM|Brando ZWZ|LINK
Hi meygnanam,
As far as I know, xslt couldn't generate two excel file.
In my opinion, one xml file means one file.
We couldn't generate the two excel file.
I suggest you could use C# select the different nodes and load different xml.
Then you could use XslCompiledTransform.Transform method to format the xml by using xslt file.
More details, you could refer to follow codes:
XML:
XSLT:
C# codes:
Result:
Best Regards,
Brando