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. save dataview as a Excel file [modified]

save dataview as a Excel file [modified]

Scheduled Pinned Locked Moved C#
question
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.
  • T Offline
    T Offline
    teymur_khan
    wrote on last edited by
    #1

    hello all, I am trying to save of importing a dataView to Excel file. dose anybody now how? discription: first I did a select to an Excel file and then I made a DataView of those selected rows and now I want to save that DataView as a Exel file. -- modified at 8:29 Thursday 18th January, 2007

    V 1 Reply Last reply
    0
    • T teymur_khan

      hello all, I am trying to save of importing a dataView to Excel file. dose anybody now how? discription: first I did a select to an Excel file and then I made a DataView of those selected rows and now I want to save that DataView as a Exel file. -- modified at 8:29 Thursday 18th January, 2007

      V Offline
      V Offline
      Vinay Dornala
      wrote on last edited by
      #2

      Hi This is the code to Export data to excel file from table in vb.net Public Sub XportToXcel(ByVal dt As DataTable) Try Dim XApp As New Excel.Application Dim XBook As Excel.Workbook = XApp.Workbooks.Add Dim XSheet As Excel.Worksheet = CType(XBook.Worksheets(1), Excel.Worksheet) XApp.Visible = False With XSheet Dim c As Long = Asc("A") For Each dc As DataColumn In dt.Columns .Cells(1, c).Value = dc.ColumnName.ToString .Cells(1, c).Font.Bold = True c += 1 Next Dim i As Long = 2 For Each dr As DataRow In dt.Rows c = Asc("A") For Each dc As DataColumn In dt.Columns .Cells(i, i - 1).Value = dr.Item(dc.ColumnName) c += 1 Next i += 1 Next XApp.Visible = True End With Catch ex As Exception MessageBox.Show("Source [" & ex.Source & "] Description [" & ex.Message & "]") End Try End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click XportToXcel(DataGrid1.DataSource) I hope this will idea for u r problem Have a Nice day

      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