Exporting Datagrid data

ekirk4

New member
Joined
Oct 28, 2005
Messages
3
Programming Experience
Beginner
I have a small program that I'm using to access data from another software thru an API. Therefore, the data I am collecting thru this API is being stored in the Datagrid of this windows form I have developed. Now I would like to have a way to export the data that is in the datagrid at any given moment, so it can be rearranged in excel. I can do a copy and paste from the datagrid, but I would like to make it easier for the user to get this information from the datagrid. Any help on how I could do this would be appreciated. All the research I have done only gives me ASP.NET stuff, no winforms. Thanks,

Eric
 
If you place the imported data in a DataTable you can then bind it to a DataGrid to display it. You can then also use ADO.NET to write it to a CSV file, which can then be opened in Excel. Using ADO.NET with text files is just like using any other data source. The folder is treated like the database and the files are the tables. See www.connectionstrings.com for the appropriate connection string. I've never done it before where the file doesn't already exist. You may have to create the empty file first. I suggest you experiment a bit to see what works.
 
Would like to do it without SQL

If I used a datatable, won't I need to use a database like SQL? I guess I could consider using an Access database. I just worry about supporting the SQL on the users PC. Would you know of any way of doing this without needing a database? Thanks,

Eric
 
The DataTable class is designed such that it is very simple to retrieve data from a database directly into one, and that is how it is generally used. That doesn't mean, however, that you can't construct and populate a DataTable yourself completely in code. There doesn't have to be a databse anywhere in sight. You simply create DataColumn objects and add them to the DataTable's Columns collection, then create DataRow objects by calling NewRow and add them to the Rows collection.
 
USE THIS INSTEAD

Once Your datagrid has been completely databound Do This...
VB.NET:
[SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] ExportData [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] genData 'I have the following sub routines in thier own "general Data" vb page.[/SIZE]
[SIZE=2] 
ExportData.RenderGridToExcelFormat(//datagridName//, "//fielnameToSave//", //CAN BE MADE OPTIONAL OR TAKEN OUT//, //CAN BE MADE OPTIONAL OR TAKEN OUT//)
[/SIZE] 
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] RenderGridToExcelFormat([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] grid [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] DataGrid, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] saveAsFile [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], _
[/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] instance [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] user [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])[COLOR=green] 'instance and user are required for some history records I have to write in my sql database. they could be removed or made optional.[/COLOR]
[/SIZE][SIZE=2][COLOR=#008000]' check Excel rows limit
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] grid.Items.Count.ToString + 1 < 65536 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strFileName [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String
[/COLOR][/SIZE][SIZE=2]strFileName = saveAsFile & " " & Replace([/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](Now, [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]), "/", "-")
strFileName = Replace(strFileName, ":", "-")
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" & strFileName & ".xls")
[/SIZE][SIZE=2][COLOR=#008000]' Remove the charset from the Content-Type header.
[/COLOR][/SIZE][SIZE=2]HttpContext.Current.Response.Charset = ""
[/SIZE][SIZE=2][COLOR=#008000]' Turn off the view state.
[/COLOR][/SIZE][SIZE=2]grid.EnableViewState = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] tw [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.IO.StringWriter
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] hw [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Web.UI.HtmlTextWriter(tw)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strStyle [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = "<style>.text { mso-number-format:\@; } </style>"
[/SIZE][SIZE=2][COLOR=#008000]' Get the HTML for the control.
[/COLOR][/SIZE][SIZE=2]grid.HeaderStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF")
grid.HeaderStyle.BackColor = System.Drawing.ColorTranslator.FromHtml("#003366")
grid.ItemStyle.ForeColor = System.Drawing.ColorTranslator.FromHtml("#003366")
grid.BorderColor = System.Drawing.ColorTranslator.FromHtml("#dddddd")
ClearControls(grid)
grid.RenderControl(hw)
SaveExport(tw.ToString(), saveAsFile, instance, user)
[/SIZE][SIZE=2][COLOR=#008000]' Write the HTML back to the browser.
[/COLOR][/SIZE][SIZE=2]HttpContext.Current.Response.Write(strStyle)
HttpContext.Current.Response.Write(tw.ToString())
[/SIZE][SIZE=2][COLOR=#008000]' End the response.
[/COLOR][/SIZE][SIZE=2]HttpContext.Current.Response.End()
[/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2]HttpContext.Current.Response.Write("Too many rows - Export to Excel not possible")
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ClearControls([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] control [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Control)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] i [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Integer
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] i = control.Controls.Count - 1 [/SIZE][SIZE=2][COLOR=#0000ff]To[/COLOR][/SIZE][SIZE=2] 0 [/SIZE][SIZE=2][COLOR=#0000ff]Step[/COLOR][/SIZE][SIZE=2] -1
ClearControls(control.Controls(i))
[/SIZE][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE][SIZE=2] i
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]TypeOf[/COLOR][/SIZE][SIZE=2] control [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2] System.Web.UI.WebControls.Image [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]control.Parent.Controls.Remove(control)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]TypeOf[/COLOR][/SIZE][SIZE=2] control [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2] TableCell) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] (control.GetType().GetProperty("SelectedItem") [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] literal [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] LiteralControl
control.Parent.Controls.Add(literal)
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]literal.Text = [/SIZE][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](control.GetType().GetProperty("SelectedItem").GetValue(control, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]))
[/SIZE][SIZE=2][COLOR=#0000ff]Catch
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]control.Parent.Controls.Remove(control)
[/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Not[/COLOR][/SIZE][SIZE=2] (control.GetType().GetProperty("Text") [/SIZE][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] literal [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] LiteralControl
control.Parent.Controls.Add(literal)
literal.Text = [/SIZE][SIZE=2][COLOR=#0000ff]CStr[/COLOR][/SIZE][SIZE=2](control.GetType().GetProperty("Text").GetValue(control, [/SIZE][SIZE=2][COLOR=#0000ff]Nothing[/COLOR][/SIZE][SIZE=2]))
control.Parent.Controls.Remove(control)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Return
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] SaveExport([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] theString [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] FileName [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], _
[/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] instance [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] user [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oFile [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.IO.File
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] oWrite [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.IO.StreamWriter
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strFileName [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = ""
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] thePath [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = ""
strFileName = FileName & " " & Replace([/SIZE][SIZE=2][COLOR=#0000ff]CType[/COLOR][/SIZE][SIZE=2](Now, [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2]), "/", "-")
strFileName = Replace(strFileName, ":", "-")
thePath = "C:\Inetpub\WWWRoot\ChainSSAllocation\ExportFiles\" & strFileName & ".xls"
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] oFile.Exists(thePath) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]oFile.Delete(thePath)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2]oWrite = oFile.CreateText(thePath)
oWrite.BaseStream.Seek(0, SeekOrigin.End)
oWrite.WriteLine(theString)
oWrite.Close()
[/SIZE][SIZE=2][COLOR=#008000]'save the fact that the user exported a screen to excel
[/COLOR][/SIZE][SIZE=2]strOhio = "INSERT INTO safety_stock_history (instance, dt_tm_added, process_type, status, process_user, export_path) " & _
"VALUES ('" & instance & "', sysdate, 'expt', 'X', '" & user.ToLower & "', '" & thePath & "')"
OhioConn.Open()
OhioCmd.Connection = OhioConn
OhioCmd.CommandText = strOhio
OhioCmd.ExecuteNonQuery()
OhioCmd.Connection = OhioConn
OhioCmd.CommandText = "commit"
OhioCmd.ExecuteNonQuery()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE]
 
Several Solutions

Hey All,

Just registered on this forum, i found a few solutions to the problem at hand...

These solutions assume you have the following:
1)reference to Excel (object library version 12. you will need to use imports Microsoft.Office.Interop.Excel)
2) A Datagrid with at least one datatable (a must have to display the data in it)

The first solution is as follows:
Having the datagrid, use a function to scan through each row in the datagrid and export that row to an excel document. Save excel document. I will post the core of this code:

VB.NET:
Public Sub ExcelExport(Optional ByVal XLLocation As String = "C:\", Optional ByVal XLFileName As String = "DataGridExport.xls")

        Dim Excel As Object
        Dim RowIndex As Integer = 0
        Dim ColumnIndex As Integer = 0
        Dim DS As DataSet = 'YourDataGrid.datasource

        'Check the datasource for tables
        If DS.Tables.Count = 0 Then
            MsgBox(" There is no data to export")
            Exit Sub
        End If
        Excel = CreateObject("Excel.application")

        'Open excel and create a workbook
        With Excel
            .SheetsInNewWorkbook = 1
            .Workbooks.Add()
            .Worksheets(1).Select()


            'Import the headers from the datagrid
            For ColumnIndex = 0 To DS.Tables(0).Columns.Count - 1
                .cells(1, ColumnIndex + 1) = DS.Tables(0).Columns(ColumnIndex).ColumnName.ToString
                .cells(1, ColumnIndex + 1).bold = True
            Next
            'import each row. Use the itemarray property to get the whole row instead of one element
            For RowIndex = 0 To DS.Tables(0).Rows.Count - 1
                .range(.cells(RowIndex + 2, 1), .cells(RowIndex + 2, DS.Tables(0).Columns.Count)) = DS.Tables(0).Rows(RowIndex).ItemArray
            Next
            'Save the location and close it
            .activeWorkbook().SaveAs(XLLocation & "\" & XLFileName)
            .activeWorkbook.close()
        End With


        MsgBox("Export Complete")
        Excel.Quit()
        Excel = Nothing
        GC.Collect()

    End Sub

This sub requires you to pass it 2 variables (Root folder and file name) used to save the excel file at the end.

Here is some code to wrap around that sub to pass it the variables in an elegant kind of way (if this is a user export)

Function to get a root folder directory
VB.NET:
    Public Function GetExportFolder() As String
        Dim FolderName As String
        Dim FolderSelector As New FolderBrowserDialog
        FolderSelector.ShowDialog()
        FolderSelector.RootFolder = Environment.SpecialFolder.Desktop
        FolderName = FolderSelector.SelectedPath.ToString
        Return FolderName
    End Function

Sub to call above function and specify a filename then pass it to the main sub
VB.NET:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Export.Click
        Dim RootFolder As String
        Dim FileName As String
        Dim File As System.IO.File
        Dim str As String
        Dim YesNo As Integer

        'Get the root folder from the exportfolder function
        RootFolder = GetExportFolder()
        If RootFolder = "" Then
            MsgBox("No File Selected")
            Exit Sub
        End If
FileStart:
        'Get a Filename from an input box
        FileName = InputBox("Please Enter a File Name", "File Name Input", "DataGridExport.xls")
        If FileName = "" Then
            MsgBox("You cant have a null filename")
            Exit Sub
        End If

        'Check the filename is correctly formatted
        If InStr(FileName, ".xls") = 0 Then
            FileName = FileName & ".xls"
        End If
        str = File.GetAttributes(RootFolder & "\" & FileName).ToString()
        'Check if that file exists
        If str = "" Then
            Call ExcelExport(RootFolder, FileName)
        Else
            'Delete File and write a new one
            YesNo = MsgBox("Overwriting old file: " & RootFolder & "\" & FileName & "?", MsgBoxStyle.YesNo)
            If YesNo = vbYes Then
                File.Delete(RootFolder & "\" & FileName)
                Call ExcelExport(RootFolder, FileName)
            Else : GoTo FileStart
            End If
        End If
    End Sub
As you can see, the above code is meant for use with a button called Button1. Feel free to modify at will :)

Solution Two is slightly more elegant. I created a new usercontrol and had it inherit control.datagrid.

Then i added a button and called it export
i made that button call the above code sets on itself so in effect i could place a datagrid with export functionality at any point.

As this is a control it is a little harder to show, i included the project in the Attachment
 

Attachments

  • CustomGrid.zip
    6.5 KB · Views: 29
This thread is from '05!

1. Using GoTo and Call is a no no.

2. Better to use Jet/ACE engines so you don't need to worry about the end user having the Office 2007 PIA. In the next version of VB.NET you'll be able to use NO-PIA to only include the interop you actually use.
 
Solution compatability

I noticed that the former solution posted was in v1.1 so i posted mine in 2003 compatible format :) as i dont use 05 i didnt know that it would not work with v2.0
 
Back
Top