NUTSHELL
I am exporting a grid that has Grid Column Groups to Excel and making changing the display of several fields from false to true. The Grid Column Group is not expanding in Excel to handle the columns which are now displayed.
DETAIL
My grid has 16 viewable columns and 6 grid column groups. When I go to Export to Excel, I change 10 additional columns so the display is true. These columns are interspersed throughout the grid and not all at the end. In Excel, the Grid Column Groups do not expand, so if they were 3columns before but now there are 6 columns under that group, it is still only 3 columns wide. This of course throws everything off.
I am programming in MS Visual Studio 2012.
I am using Telerik UI for ASP.NET AJAX, v.2014.1.225.45
CODE
HTML
I won't bother to post the HTML until asked, but here is the code for the GridColumnGroup and one of the non-displayed columns.
Thank you!
I am exporting a grid that has Grid Column Groups to Excel and making changing the display of several fields from false to true. The Grid Column Group is not expanding in Excel to handle the columns which are now displayed.
DETAIL
My grid has 16 viewable columns and 6 grid column groups. When I go to Export to Excel, I change 10 additional columns so the display is true. These columns are interspersed throughout the grid and not all at the end. In Excel, the Grid Column Groups do not expand, so if they were 3columns before but now there are 6 columns under that group, it is still only 3 columns wide. This of course throws everything off.
I am programming in MS Visual Studio 2012.
I am using Telerik UI for ASP.NET AJAX, v.2014.1.225.45
CODE
Protected
Sub
btnExport_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Me
.RadGrid1.MasterTableView.GetColumn(
"Location"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_NotIssued"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_NotIssuedReason"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_Qualification"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_EstimatedProjectArea"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_EstimatedConstructionCost"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_WinningProbabilityPct"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_DateGranted"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_ProjectID"
).Display =
True
Me
.RadGrid1.MasterTableView.GetColumn(
"Proposal_Comments"
).Display =
True
For
Each
item
As
GridDataItem
In
Me
.RadGrid1.Items
If
item.Selected =
False
Then
item.Visible =
False
End
If
Next
Me
.RadGrid1.ExportSettings.ExportOnlyData =
True
Me
.RadGrid1.ExportSettings.OpenInNewWindow =
True
Me
.RadGrid1.ExportSettings.FileName =
"Selected Proposals "
& Format(Now,
"yyyy-MM-dd-h-mm-ss"
)
'Me.RadGrid1.ExportSettings.IgnorePaging = True
Me
.RadGrid1.ExportSettings.UseItemStyles =
True
Me
.RadGrid1.MasterTableView.ExportToExcel()
End
Sub
HTML
I won't bother to post the HTML until asked, but here is the code for the GridColumnGroup and one of the non-displayed columns.
<
ColumnGroups
>
<
telerik:GridColumnGroup
HeaderText
=
"Proposal"
Name
=
"Proposal"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
<
telerik:GridColumnGroup
HeaderText
=
"Fee"
Name
=
"Fee"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
<
telerik:GridColumnGroup
HeaderText
=
"Key Dates"
Name
=
"Dates"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
<
telerik:GridColumnGroup
HeaderText
=
"Client"
Name
=
"Client"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
<
telerik:GridColumnGroup
HeaderText
=
"Owner"
Name
=
"Owner"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
<
telerik:GridColumnGroup
HeaderText
=
"DLB"
Name
=
"DLB"
HeaderStyle-HorizontalAlign
=
"left"
>
<
HeaderStyle
HorizontalAlign
=
"Left"
></
HeaderStyle
>
</
telerik:GridColumnGroup
>
</
ColumnGroups
>
<
telerik:GridBoundColumn
Display
=
"False"
DataField
=
"Proposal_Qualification"
ColumnGroupName
=
"Proposal"
HeaderStyle-Height
=
"44px"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-VerticalAlign
=
"Middle"
FilterControlAltText
=
"Filter Proposal_Qualification column"
HeaderText
=
"Qualification"
SortExpression
=
"Proposal_Qualification"
UniqueName
=
"Proposal_Qualification"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
<
HeaderStyle
HorizontalAlign
=
"Left"
VerticalAlign
=
"Middle"
Height
=
"44px"
></
HeaderStyle
>
<
ItemStyle
Width
=
"105px"
></
ItemStyle
>
</
telerik:GridBoundColumn
>
Thank you!