PDA

Click to See Complete Forum and Search --> : Export Data to Excel


Susrutha
Sep 27th, 1999, 09:56 PM
I'm trying to save the information in my Grid to an Excel Sheet but I'm getting an error "Method or Datamembership not found". It's not accepting the property DataGrid1.Rows or Cols. Is there anyway to solve this problem. Please help.

Dim xlApp As New Excel.Application
Dim xlSheet As Worksheet
Dim xlBook As Workbook
Dim iCol As Integer
Dim iRow As Integer

Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add

For iRow = 0 To DataGrid1.Rows - 1
DataGrid1.Row = iRow
For iCol = 0 To DataGrid1.Cols - 1
DataGrid1.Col = iCol
xlSheet.Cells(iRow + 1, iCol + 1) = DataGrid1.Text
Next
Next

xlBook.SaveAs "C:\MyGridFile.xls"
xlSheet.Application.Quit

Set xlSheet = Nothing
Set xlBook = Nothing
Set xlApp = Nothing


[This message has been edited by Susrutha (edited 09-28-1999).]

[This message has been edited by Susrutha (edited 09-28-1999).]

JHausmann
Sep 29th, 1999, 12:45 AM
For the number of rows in your Datagrid, try using the

ApproxCount property (or the recordset's recordcount property for the grid's bound control)

For the number of columns, try

columns.count