Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting data from Janus GridEx

Status
Not open for further replies.

bradth

IS-IT--Management
Feb 18, 2005
142
CA
I currently have a form that contains 3 text boxes and a Janus GridEx. When the 3 text boxes are filled with information, a run button is pressed and calls a stored procedure that will populate the grid. There are 7 columns in the grid. Only one of the columns is editable and left blank so the user can enter data into that column. Is there a way to export the contents from the Janus GridEx to Excel or a spreadsheet of some sort? I am able to export the data to Excel from the stored procedure, however that doesn't include the data the user enters in. I need the spreadsheet to contain all of the data that the user entered in as well. Any suggestions would be much appreciated. Thanks.

Brad [spidey]
 
You will need to go through each row of the grid and add it to a spreadsheet manually, unless your grid supports exporting. Here's how I've done it:
Code:
'   Export the grid to an excel spreadsheet

    Dim row As Long
    Dim Col As Long
    Dim wkbNew As Excel.Workbook
    Dim wkbSheet As Excel.Worksheet

    On Error GoTo exportErr

    Application.SheetsInNewWorkbook = 1
    Set wkbNew = Workbooks.Add

    Set wkbSheet = wkbNew.Worksheets(1)

    wkbSheet.Range("a1:z1").Font.bold = True
    For Col = 0 To fg.cols - 1
        For row = 0 To fg.Rows - 1
             wkbSheet.Cells(row + 1, Col + 1) = fg.TextMatrix(row, Col)
        Next
    Next

    If sendEmail Then

'   Email the spreadsheet

        wkbNew.SendMail "", subject
        wkbNew.Close False
    Else

'   Close and save the file - create default file name if full name not passed

        If InStr(1, gridName, "xls") = 0 Then _
        gridName = "c:\temp\" + gridName + "_" + Format(Now, "yyyymmdd_hhmmss") +
".xls"

        wkbNew.SaveAs gridName
        wkbNew.Close True
    End If

"I think we're all Bozos on this bus!" - Firesign Theatre [jester]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top