We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Excel Export (Unbound Fields)

Thread ID:

Created:

Updated:

Platform:

Replies:

107256 Feb 21,2013 11:30 AM Feb 27,2013 05:54 AM ASP.NET Web Forms (Classic) 1
loading
Tags: GridGroupingControl
Dale Norhern
Asked On February 21, 2013 11:30 AM

Hello,

I have a Grid Grouping Control that has both bound, and unbound columns.  I am setting the values of the unbound columns in the RowDataBound event, and all is well.  Now I have a need to export the entire grid to Excel.  I am using the following code:

Dim excel As New GridExcelExport(Me.GridGroupingControl1, "C:\ReworkCost.xls", ConverterOptionsExt.Visible)
excel.ExportNestedTable = True
excel.Export()  

I have also tried "ConverterOptionsExt.All".  The problem is that the unbound cells are empty in the Excel Export.  I found a previous post on this subject at http://www.syncfusion.com/support/forums/grid-aspnet/102027 where Syncfusion stated "We can only export the bound columns to the excel/word".  I am hoping that this is incorrect, or has changed since 2011.  What is the point of an export function, if it doesn't work 100%?

I need to export a grid to Excel with all of the data intact (both bound and unbound fields).

Visual Studio 2010
.NET Framework 4.0
Essential Studio 10.4.0.71
VB.Net Code behind

Thanks!

--Dale


Ranjithkumar R G [Syncfusion]
Replied On February 27, 2013 05:54 AM

Hi Dale,

 

Thanks for using Syncfusion products.

 

We suggest you to inherit the GridExcelExport class and override the CopyStyles method to achieve your requirement. Please refer to the code snippet below.

 

  Public Class mycustomExport

        Inherits GridExcelExport

        Public Sub New(ByVal ggc As GridGroupingControlByVal fileName As String)

 

            MyBase.New(ggc, fileName)

        End Sub

 

 

        Protected Overrides Sub CopyStyles(ByVal style As GridTableCellStyleInfoByVal rowIdx As IntegerByVal colIdx As Integer)

 

            Dim range As IRange = Me.Sheet(rowIdx, colIdx)

 

            If style.TableCellIdentity.DisplayElement.Kind = DisplayElementKind.Record AndAlso style.TableCellIdentity.Column.HeaderText = "TestCurrency" Then

                Dim nTest As Double = 0.0

                nTest = rowIdx + 1

                Dim nPi As Double = nTest * Math.PI

 

                range.Text = String.Format("{0:C}", nPi)

            End If

 

 

        End Sub

    End Class

 

 

Sample link: sample.zip

 

Please let us know if you have any concern.

 

Regards,

Ranjithkumar.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;