-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: DesignedforDOTNet
Message 2 in Discussion

hi...   not able to exactly able to point out the error..... but i have an alternate 
solution, you can try it out.... this example writes the dataset contents to an excel 
file using XML and XSLT.   *********Code for writing the dataset to excel************  
// Response.ContentType = "application/vnd.ms-excel"; 
// Response.Charset = ""; 
DataSet ds = new DataSet(); 
ds.ReadXml( @"E:\Kannan\XMLtoExcel Sample APP\sampleXML.xml"); 
XmlDataDocument xdd = new XmlDataDocument(ds); 
XslTransform xt = new XslTransform(); 
xt.Load(@"E:\Kannan\XMLtoExcel Sample APP\xslSheet.xsl"); 
//StreamWriter sw = new StreamWriter("c:\\test.xls"); 
FileStream fs = new FileStream("c:\\test1.xls",FileMode.Create); 
using (fs) 
{ 
xt.Transform(xdd, null, fs); 
} 
save this code below as an XSLT file to the path specified in the above code block 
*********XSLT file************ 
<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: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="/"> 
<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";> 
<xsl:apply-templates/> 
</Workbook> 
</xsl:template> 
  
<xsl:template match="/*"> 
<Worksheet> 
<xsl:attribute name="ss:Name"> 
<xsl:value-of select="local-name(/*/*)"/> 
</xsl:attribute> 
<Table x:FullColumns="1" x:FullRows="1"> 
<Row> 
<xsl:for-each select="*[position() = 1]/*"> 
<Cell><Data ss:Type="String"> 
<xsl:value-of select="local-name()"/> 
</Data></Cell> 
</xsl:for-each> 
</Row> 
<xsl:apply-templates/> 
</Table> 
</Worksheet> 
</xsl:template> 
  
<xsl:template match="/*/*"> 
<Row> 
<xsl:apply-templates/> 
</Row> 
</xsl:template> 
  
<xsl:template match="/*/*/*"> 
<Cell><Data ss:Type="String"> 
<xsl:value-of select="."/> 
</Data></Cell> 
</xsl:template> 
</xsl:stylesheet> 
bye 
the same code is there in my blog, you can even check it out there..... 
Kannan.V 
Blog : http://kannanv.blogspot.com

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/BDotNet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you received 
this message by mistake, please click the "Remove" link below. On the pre-addressed 
e-mail message that opens, simply click "Send". Your e-mail address will be deleted 
from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to