Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. export dataset to excel file

export dataset to excel file

Scheduled Pinned Locked Moved ASP.NET
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bhavna4321
    wrote on last edited by
    #1

    i want to export dataset at runtime to an excel file. i had tried but in vain. Pleaae help me with some link to work out. Thnks in advance.

    L 1 Reply Last reply
    0
    • B bhavna4321

      i want to export dataset at runtime to an excel file. i had tried but in vain. Pleaae help me with some link to work out. Thnks in advance.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi Bhavna, The requirement is fissible via Gridview control or XmlDocument but I think your requirement is without gridview, We need to do the requirement as below

      DataSet DS = somevalueDataSet();
      XmlDataDocument xdd = new XmlDataDocument(DS);
      XslTransform xt = new XslTransform();
      string workingdir = AppDomain.CurrentDomain.BaseDirectory + "/" + "xslSheet.xsl";
      xt.Load(workingdir);
      string dirPath = AppDomain.CurrentDomain.BaseDirectory + "/" + "GeneratedFR";
      string filePath = AppDomain.CurrentDomain.BaseDirectory + "/" + "GeneratedFR" + "/" + "Test1.xls";
      if (!Directory.Exists(dirPath))
      {
      Directory.CreateDirectory(dirPath);
      }
      File.Delete(filePath);
      FileStream fs = new FileStream(filePath, FileMode.Create);
      using(fs)
      {
      xt.Transform(xdd,null,fs);
      fs.Close();
      }

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups