Write As XML with .XLS extensions

Today I want to share with you how to write XML file as an excel file from DataTable. Here I  provide you a function where you just send a DataTable as a parameter and this function is responsible for generate the Excel file.

     public void ExportAsXMLtoXLS(DataTable dt)
        System.Data.DataTable dt = GetData();
        dt.TableName = "Employees";
        dt.WriteXml(Server.MapPath(".")+ @"\GenerateData.xls", XmlWriteMode.IgnoreSchema);


Popular posts from this blog

The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

"This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."

Check/Uncheck all items in a CheckBoxList using Javascript