Ravendra's Blog

October 29, 2009

How to convert XML Data into Excel

Filed under: Uncategorized — Ravendra Mishra @ 12:31 pm

using System;
using System.Data;
using System.IO;
using System.Xml;
using System.Xml.Xsl;
namespace XML2Excel
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                throw new Exception(“Usage: XML2Excel XMLFileName XSLName ExcelFileNameToCreate”);       
            }

            DataSet ds = new DataSet();
            ds.ReadXml(args[0]);
            XmlDataDocument xdd = new XmlDataDocument(ds);
            XslTransform xt = new XslTransform();
            xt.Load(args[1]);

            StreamWriter swriter = new StreamWriter(args[2]);
           
            xt.Transform(xdd, null, swriter.BaseStream);           
        }
    }
}

Hello world!

Filed under: Uncategorized — Ravendra Mishra @ 10:27 am

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Blog at WordPress.com.