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. General Programming
  3. C#
  4. export data from datagrid to excel [modified]

export data from datagrid to excel [modified]

Scheduled Pinned Locked Moved C#
csharp
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.
  • M Offline
    M Offline
    Mamphekgo
    wrote on last edited by
    #1

    Hi everyone I am trying to export data from datagrid to excel but gives me this erro"Obect reference not set to instance of the object".here is my code.I am using windows C#. lblMessage.Text = ""; DataTable dtTransactions = dsTransactions.Tables["Transactions"].Copy(); int[] iColumns = {0,1,2,3,5,6}; RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win"); objExport.ExportDetails(dtTransactions,iColumns,Export.ExportFormat.Excel,"C:\\TransactionsInfo.Excel"); lblMessage.Text = "Successfully exported to C:\\TransactionsInfo.Excel"; -- modified at 8:28 Thursday 31st August, 2006

    N 1 Reply Last reply
    0
    • M Mamphekgo

      Hi everyone I am trying to export data from datagrid to excel but gives me this erro"Obect reference not set to instance of the object".here is my code.I am using windows C#. lblMessage.Text = ""; DataTable dtTransactions = dsTransactions.Tables["Transactions"].Copy(); int[] iColumns = {0,1,2,3,5,6}; RKLib.ExportData.Export objExport = new RKLib.ExportData.Export("Win"); objExport.ExportDetails(dtTransactions,iColumns,Export.ExportFormat.Excel,"C:\\TransactionsInfo.Excel"); lblMessage.Text = "Successfully exported to C:\\TransactionsInfo.Excel"; -- modified at 8:28 Thursday 31st August, 2006

      N Offline
      N Offline
      narendrakumarp
      wrote on last edited by
      #2

      Response.Clear(); Response.Charset = ""; Response.AddHeader("content-isposition", "attachment;filename=FileName.xls"); Response.ContentType = "application/vnd.ms-excel"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); DataGrid dGrid = new DataGrid(); dGrid.DataSource = Classname.functionname();//this is where u write the stored procedure dGrid.HeaderStyle.Font.Bold = true; dGrid.DataBind(); dGrid.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End();

      please help me

      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