Convert XML To an Excel Spreadsheet Using XSL
page 4 of 5
by Andrew Mooney
Feedback
Average Rating: 
Views (Total / Last 10 Days): 174208/ 292

Use ASP.NET To Transform The XML

[Download Code]
The first thing the ASP.NET page does is set the content type to MS Excel. It then opens the XML file as an XML data document, transforms it with XSL, and sends it to the client's browser.

<%@ Page Language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Xml.Xsl" %>
<script language="C#" runat="server">
    public void Page_Load(Object sender, EventArgs E) {
        Response.ContentType = "application/vnd.ms-excel";
        Response.Charset = "";
        DataSet ds = new DataSet();
        ds.ReadXml(Server.MapPath("Authors.xml"));
        XmlDataDocument xdd = new XmlDataDocument(ds);
        XslTransform  xt = new XslTransform();
        xt.Load(Server.MapPath("Excel.xsl"));
        xt.Transform(xdd, null, Response.OutputStream);
        Response.End();              
      }
</script>


View Entire Article

User Comments

No comments posted yet.






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2018 ASPAlliance.com  |  Page Processed at 2018-10-21 6:22:41 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search