This is a migrated thread and some comments may be shown as answers.

'Item' is not member RadGridView

3 Answers 138 Views
GridView
This is a migrated thread and some comments may be shown as answers.
darwin mateo
Top achievements
Rank 1
darwin mateo asked on 10 Dec 2019, 10:29 PM

Code

Public Function NuevoExport(ByVal Grilla As RadGridView, ByVal Grilla2 As RadGridView) As Boolean

 For fila = 0 To Grilla.RowCount - 1
                For col As Integer = 0 To Ncol - 1
                    exHoja.Cells.Item(fila + 2, col + 1) = Grilla.Item(col, fila).Value
                Next
            Next

 

3 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Dec 2019, 05:42 AM

Hi, Darwin,

The provided brief description is not enough to understand the exact problem that you are facing. Could you please give us some more details about the precise case that you have and the exact goal that you are trying to achieve? Thus, we would get better understanding of the precise case and assist you further. Thank you in advance.

I am looking forward to your reply.

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
darwin mateo
Top achievements
Rank 1
answered on 11 Dec 2019, 02:28 PM
Good morning, I'm trying to export two grids on an excel sheet, but I get the error 'Item' is not member of radgridview
                   
Public Function NuevoExport(ByVal Grilla As RadGridView, ByVal Grilla2 As RadGridView) As Boolean
       Dim exApp As New Microsoft.Office.Interop.Excel.Application
       Dim exLibro As Microsoft.Office.Interop.Excel.Workbook
       Dim exHoja As Microsoft.Office.Interop.Excel.Worksheet
 
 
       Try
           exLibro = exApp.Workbooks.Add
 
           exHoja = CType(exLibro.Worksheets.Add(), Excel.Worksheets)
           Dim Ncol As Integer = Grilla.ColumnCount
           Dim NRow As Integer = Grilla.RowCount + Grilla2.Rows.Count
 
           Dim i As Integer = 1
           For i = 1 To Ncol
               exHoja.Cells.Item(1, i) = Grilla.Columns(i - 1).Name.ToString
           Next
           Dim fila As Integer = 0
           For fila = 0 To Grilla.RowCount - 1
               For col As Integer = 0 To Ncol - 1
                   exHoja.Cells.Item(fila + 2, col + 1) = Grilla.Item(col, fila).Value
               Next
           Next
           fila += 1
           Dim cambio As Microsoft.Office.Interop.Excel.Range = exHoja.Range("A" & fila, i & fila)
           fila += 1
           cambio.Merge()
 
           Dim fila2 As Integer = 0
           Dim Datos As String = ""
 
           cambio.Value = "Cambio de dgv"
           For fila2 = 0 To Grilla2.RowCount - 1
               For col As Integer = 0 To Grilla2.ColumnCount - 1
                     exHoja.Cells.Item(fila, col + 1) = Grilla2.Item(col, fila).Value
               Next
               fila += 1
 
           Next
 
           Dim Rango As Microsoft.Office.Interop.Excel.Range = exHoja.Range("", "" & fila)
           Rango.Columns.AutoFit()
           Rango.HorizontalAlignment = 3
           exApp.Application.Visible = True
 
           exHoja = Nothing
           exLibro = Nothing
           exApp = Nothing
 
 
           'cambio.Columns()
           'cambio.HorizontalAlignment = 3
 
 
       Catch ex As Exception
 
       End Try
       Return True
   End Function

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Dec 2019, 10:49 AM
 

Hello, Darwin,    

The provided sample code snippet is greatly appreciated.

Firstly, I would like to note that RadGridView offers the GridViewSpreadExport which utilizes our RadSpreadProcessing library to export the content of RadGridView to xlsx, csv, pdf and txt formats. The FileExportMode determines whether the grid's data will be exported into an existing (on a new sheet) or a new file. If new is chosen and such exists it will be overridden. Additional information is available in the following help article: https://docs.telerik.com/devtools/winforms/controls/gridview/exporting-data/spread-export

You can also refer to our Demo application >> GridView >> Export >> Export with Document Processing Libraries example. The Demo application is usually located in the installation folder of the suite. 

As to the question at hand, it seems that you are using the Microsoft.Office.Interop.Excel.Worksheet from where you access the Cells collection and try to get the Cells.Item passing row/column index. Actually, it is not related to RadGridView from the Telerik UI for WinForms suite. This question is relevant for general programming forums like MSDN and StackOverflow. The following threads are quite useful on this topic:

https://stackoverflow.com/questions/18993735/how-to-read-single-excel-cell-value

https://social.msdn.microsoft.com/Forums/vstudio/en-US/c121f514-1692-46c5-91d2-18ec3db9019b/how-access-a-excel-cell-by-its-name?forum=exceldev


I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
darwin mateo
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
darwin mateo
Top achievements
Rank 1
Share this question
or