BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
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
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 GridGroupingControl, ByVal fileName As String)
MyBase.New(ggc, fileName)
End Sub
Protected Overrides Sub CopyStyles(ByVal style As GridTableCellStyleInfo, ByVal rowIdx As Integer, ByVal 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.