Gridview:ColumnGroupsView:Export to ExcelML

15 posts, 0 answers
  1. Gourangi
    Gourangi avatar
    83 posts
    Member since:
    Mar 2008

    Posted 24 Sep 2009 Link to this post

    Hi
        I am using gridview with columnGroupsView as viewdefination and setting some columns manually as

     

    While exporting the content of gridview to excel i am getting the below error but if i set the view defination as tableview it works fine.

    Error :System.ArgumentOutOfRangeException was unhandled
      Message="Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"

    Getting the above error for:

     

     

    exporter.RunExport(fileName.ToString())  where exporter is object of ExportToExcelML

    Columns of gridview are:

    columnGroupsView = New ColumnGroupsViewDefinition()

     

    columnGroupsView.ColumnGroups.Add(

    New GridViewColumnGroup("City"))

     

    columnGroupsView.ColumnGroups.Add(

    New GridViewColumnGroup("Details"))

     

     

    columnGroupsView.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())

     

    columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(gridViewStaus.Columns(

    "LOCATION"))

     

    columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(gridViewStaus.Columns(

    "ID"))

     

     

    columnGroupsView.ColumnGroups(1).Groups.Add(New GridViewColumnGroup("Fault"))...

     

     


    Please help!

     

  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 26 Sep 2009 Link to this post

    Hi Divyesh Chapaneri,

    Thank you for contacting us.

    Unfortunately I was not able to reproduce this issue. However, I will investigate it further. Could you please send me your application. This will help me locating the issue and finding a proper solution. Thank you in advance for your cooperation.

    Greetings,
    Jack
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Prad
    Prad avatar
    35 posts
    Member since:
    Apr 2008

    Posted 28 Sep 2009 Link to this post

    Hi Jack,

      I had a similar issue and is resolved in the "internal build" which I believe will be released in the next Service Pack?

    Pradeep
  5. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 29 Sep 2009 Link to this post

    Hi Divyesh Chapaneri,

    We believe that we have addressed this exception in the latest internal build as Pradeep said. Currently, we have not plans for Service Pack release, but the fix will be available in the next major version Q3 2009. You can download the latest internal build from your account and give it a try.

    All the best,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Ufuk KARTAL
    Ufuk KARTAL avatar
    1 posts
    Member since:
    Dec 2009

    Posted 03 Feb 2010 Link to this post

    hi
    first of all sory for my bad language
    I am using q3 2009
    this my code

    Me.columnGroupsView = New ColumnGroupsViewDefinition()

     

     

    Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup("Genel"))

     

    Me.columnGroupsView.ColumnGroups(0).Rows.Add(New GridViewColumnGroupRow())

     

    Me.columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns("NVU_ID"))

     

    Me.columnGroupsView.ColumnGroups(0).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns("NVU_PERSON_NAME"))

     

    For i = 1 To mDay(tmpDt1.Month)

     

    Me.columnGroupsView.ColumnGroups.Add(New GridViewColumnGroup(i.ToString))

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows.Add(New GridViewColumnGroupRow())

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PROD1"))

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PROD2"))

     

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PROD3"))

     

     

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PROD4"))

     

     

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PRODINS"))

     

     

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PRODINS_2"))

     

     

     

    Me.columnGroupsView.ColumnGroups(i.ToString).Rows(0).Columns.Add(Me.grdMainGunBeGun.Columns(i.ToString & "PRODINS_3"))

     

     

     

    Next

    this code running after my datatable bound to grid
    in my datatable columns like 1PROD1, 1PROD2, 1PROD3, 1PROD4 ........ 2PROD1, 2PROD2.......
    when i try to save excel
    i am not looking this columns in excel file only orginally columns in excel file
    and this is my excel save code:

     

     

     

    Dim myForm As New SaveFileDialog 

     

    Dim dr As String = myForm.ShowDialog

     

     

     

    Dim fName As String = myForm.FileName

     

     

     

    myExp = New Export.ExportToExcelML(grd)

     

     

     

    myExp.HiddenColumnOption = Telerik.WinControls.UI.Export.HiddenOption.DoNotExport

     

     

     myExp.SummariesExportOption = SummariesOption.ExportAll

    myExp.SheetName =

    "NavimSheet"

     

     

     

     

    myExp.SheetMaxRows = ExcelMaxRows._65536

     

     

    myExp.ExportVisualSettings = ExportWithVisualSetting

     

    myExp.RunExport(fName)

     

     

     MsgBox(

     

    "Excel saved")


    please help

    how can i saved to excel with this ColumnGroupsViewDefinition columns

    thanks

     

     

     

     

     

  7. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 09 Feb 2010 Link to this post

    Hi Ufuk KARTAL,

    Thank you for contacting us.

    ExportToExcelML class does not support exporting grid with ColumnGroupsViewDefinition. We will include this functionality in one of the feature releases.

    I have updated your Telerik points for bringing this to our attention. Do not hesitate to contact me again if you have any other questions.

    Best wishes,
    Martin Vasilev
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  8. Marcello
    Marcello avatar
    8 posts
    Member since:
    Dec 2008

    Posted 08 Sep 2014 in reply to Martin Vasilev Link to this post

    Hi, 
    there's something new on this topic?

  9. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 11 Sep 2014 Link to this post

    Hello Marcello,

    Thank you for writing.

    Currently, RadGridView does not support export to Excel functionality for ColumnGroupsViewDefinition. You can track the feature request's progress, subscribe for status changes and add your vote/comment to it on the following link - feedback item. Since we have already introduced the Document processing library in the Telerik UI for WinForms suite we will consider this feature in the next releases.

    I hope this information helps. Should you have further questions, I would be glad to help.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  10. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 16 Sep 2014 Link to this post

    Hello Marcello,

    It seems that there is a duplicate of this feature request. Here is the feedback item for your reference regarding the export functionality of RadGridView view definitions (ColumnGroupsViewDefinition and HtmlViewDefinition) : ADD. RadGridView - add export of ViewDefinition. The votes are transferred accordingly.

    Regards,
    Desislava
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  11. kent
    kent avatar
    7 posts
    Member since:
    Jul 2014

    Posted 16 Aug in reply to Dess Link to this post

    The feature request now shows a status of "completed" as of December 2015.  However, I can't find an example of how to implement this using VB.NET.

    What version did this become available in?  I am using 2016.2.608.40.

    Could you please provide an example of how to utilize this new feature?

    Here is a generic code snippet that could be called from a button, etc. to export 'RadGridView1' which has a ColumnGroupsViewDefinition applied to it.

                With New SaveFileDialog

                    .Filter = "Excel Spreadsheet (*.xlsx)|*.xlsx"

                    .FilterIndex = 1

                    .Title = "Export Grid to File"

                    .FileName = fileName

                    If .ShowDialog() = DialogResult.OK Then

                        Dim spreadExporter As New GridViewSpreadExport(RadGridView1)

                        Dim exportRenderer As New SpreadExportRenderer()

                        spreadExporter.ExportFormat = SpreadExportFormat.Xlsx

                        spreadExporter.SheetName = sheetName

                        spreadExporter.ExportVisualSettings = True

                        spreadExporter.SummariesExportOption = SummariesOption.ExportOnlyTop

                        spreadExporter.SheetMaxRows = ExcelMaxRows._1048576

                        spreadExporter.HiddenColumnOption = HiddenOption.DoNotExport

                        spreadExporter.HiddenRowOption = HiddenOption.DoNotExport

                        spreadExporter.FileExportMode = FileExportMode.CreateOrOverrideFile

                        spreadExporter.ExportViewDefinition = True

                        spreadExporter.ExportGroupedColumns = True

                        Try
                            spreadExporter.RunExport(.FileName, exportRenderer)
                            Process.Start(.FileName)
                        Catch ioEx As IOException
                            MessageBox.Show(ioEx.Message.ToString, "Info")
                        End Try

                    End If

                End With

     

    Thanks in advance.

    Kent

  12. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 17 Aug Link to this post

    Hello Kent,

    Thank you for writing. 

    I have prepared a sample project demonstrating how to export ColumnsGroupViewDefinition in RadGridView. Please refer to the attached screenshot illustrating the result on my end with the latest version. The following help article is quite useful as well: http://docs.telerik.com/devtools/winforms/gridview/exporting-data/spread-export

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  13. kent
    kent avatar
    7 posts
    Member since:
    Jul 2014

    Posted 17 Aug in reply to Dess Link to this post

    Hi Dess,

    Thanks for responding so quickly.  Your sample project seems to work fine, but when I add in the two additional lines required in my code base the export still fails.

    Two lines of code from your sample that I added into my project:

    spreadExporter.ExportViewDefinition = True
    spreadExporter.ExportGroupedColumns = True

    For your knowledge, I had tried this prior to posting yesterday and it didn't work.  I then looked at the help article that you posted, and it didn't indicate that I was missing something.  Hence, my initial post about this.

    Moving on... when I try to run the export, this line of code fails:

    spreadExporter.RunExport(.FileName, exportRenderer)

    This is the error generated:

    System.ArgumentOutOfRangeException was unhandled by user code
      HResult=-2146233086
      Message=Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index
      ParamName=index
      Source=mscorlib
      StackTrace:
           at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
           at System.Collections.Generic.List`1.get_Item(Int32 index)
           at Telerik.WinControls.Export.GridViewSpreadExport.ProcessGroup(ColumnGroupRowLayout columnGroupRowLayout, GridViewColumnGroup group, GroupNode node)
           at Telerik.WinControls.Export.GridViewSpreadExport.CreateRowSpanCells(ColumnGroupRowLayout columnGroupRowLayout)
           at Telerik.WinControls.Export.GridViewSpreadExport.AddViewDefinitionRow(GridViewRowInfo gridViewRowInfo, TableViewRowLayoutBase rowLayout, Int32 rowIndex)
           at Telerik.WinControls.Export.GridViewSpreadExport.ProcessRows(ExportGridTraverser traverser, TableViewRowLayoutBase rowLayout, Int32 currentRowNum)
           at Telerik.WinControls.Export.GridViewSpreadExport.ExportToStream(Stream stream)
           at Telerik.WinControls.Export.GridViewSpreadExport.RunExportCall(String fileName)
           at Telerik.WinControls.Export.GridViewSpreadExport.RunExport(String fileName, ISpreadExportRenderer exportRenderer)
           at ******.Utilities.TelerikExportGridToExcel(RadGridView spread, String fileName, String sheetName) in ...

    Does that help?  Am I missing something in the code that creates the viewDefinition?  The grid appears correctly.  I have attached a screenshot for reference.

    Any help would be appreciated.

    Thanks,

    Kent

  14. kent
    kent avatar
    7 posts
    Member since:
    Jul 2014

    Posted 17 Aug in reply to kent Link to this post

    Also, your sample project was pointing to the same Telerik .dlls that I am using.  It was referencing the .NET framework 4.5 whereas my project is referencing 4.6.  I really don't know if that would make a difference, but wanted to let you know just in case.

    Thanks,

    Kent

  15. kent
    kent avatar
    7 posts
    Member since:
    Jul 2014

    Posted 17 Aug in reply to kent Link to this post

    Sorry for all the posts.

    I have this running as a common routine which is utilized by many grids within the application.  Even with the two new lines of code that reference viewDefinitions and exporting column groups, it works fine with all the other grids.  This is the only grid that uses a viewDefinition to create column groups, and the only grid that the export fails on.

    The first parameter in this routine is the RadGridView (which I presume also contains the viewDefinition).  The other two parameters are strings for the suggested filename and the sheetname.

    Thanks,

    Kent

  16. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 19 Aug Link to this post

    Hello Kent, 

    Thank you for writing back. 

    I am still unable to replicate the error you are facing. It seems to be something specific in that particular grid. That is why I would kindly ask you to open a support ticket and provide a sample project demonstrating the issue. If it is more convenient to you, feel free to modify my sample project in a way to reproduce the exception. This would be the fastest way to make an adequate analysis of the problem and assist you further. Thank you in advance.

    I am looking forward to your reply.

    Regards,
    Dess
    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready