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