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

Alignment problem with hierarchical RadGrid export

4 Answers 160 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Swapnil
Top achievements
Rank 1
Swapnil asked on 22 Aug 2016, 06:49 AM

I am facing alignment issue while exporting hierarchical radgrid data to excel. Please find below by code

ASPX

<telerik:RadGrid ID="RadGridCurrencyDetail" runat="server" AutoGenerateColumns="False"
                                    CellSpacing="0" GridLines="None" Width="100%" OnNeedDataSource="RadGridCurrencyDetail_NeedDataSource" OnGridExporting="RadGridCurrencyDetail_GridExporting">
                                    <AlternatingItemStyle Wrap="True" />
                                    <GroupHeaderItemStyle Wrap="True" />
                                    <ClientSettings AllowExpandCollapse="true">
                                    </ClientSettings>
                                     <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" />
                                    <MasterTableView AllowMultiColumnSorting="false" AutoGenerateColumns="false" TableLayout="Fixed"
                                        AllowFilteringByColumn="false" AllowSorting="false" IsFilterItemExpanded="false"
                                        NoMasterRecordsText="No currency records in this Queue" DataKeyNames="BucketID,BucketID"
                                        HierarchyLoadMode="Client" HierarchyDefaultExpanded="true">
                                        <%--<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                            <HeaderStyle Width="3%"></HeaderStyle>
                                        </ExpandCollapseColumn>--%>
                                        <Columns>
                                            <telerik:GridTemplateColumn DataField="BucketName" FilterControlAltText="BucketName"
                                                HeaderText="Bucket" UniqueName="BucketName">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblBucketName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "BucketName")%>'></asp:Label>
                                                </ItemTemplate>
                                               

                                                 <ItemStyle HorizontalAlign="Left" CssClass="SlimCell" Wrap="false" />
                                                 <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                  HorizontalAlign="Left" Width="25%" />
                                            </telerik:GridTemplateColumn>

                                            <telerik:GridTemplateColumn DataField="Broker" DataType="System.Decimal" FilterControlAltText="Filter Broker column"
                                                UniqueName="BrokerValue" HeaderText="Broker">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblBroker" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "BrokerValue")%>'></asp:Label><%--C1---%>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Right" CssClass="SlimCell" Wrap="false" />
                                                <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                    HorizontalAlign="Left" Width="25%" />
                                            </telerik:GridTemplateColumn>

                                            <telerik:GridTemplateColumn DataField="System" DataType="System.Decimal" FilterControlAltText="Filter System column"
                                                HeaderText="System" UniqueName="SystemValue">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblSystem" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "SystemValue")%>'></asp:Label>
                                                    <%--C1---%>
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Right" CssClass="SlimCell" Wrap="false" />
                                                <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                    HorizontalAlign="Left" Width="25%" />
                                            </telerik:GridTemplateColumn>
                                            <telerik:GridTemplateColumn DataField="TotalDiff" FilterControlAltText="TotalDiff"
                                                HeaderText="Difference" UniqueName="TotalDiff">
                                                <ItemTemplate>
                                                    <asp:Label ID="lblTotalDiff" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "TotalDiff")%>'></asp:Label>
                                                </ItemTemplate>
                                                <ItemStyle CssClass="cItem" HorizontalAlign="right" VerticalAlign="Top" />
                                                <HeaderStyle Width="25%" VerticalAlign="Top" CssClass="OTCs_gridHeader_left" HorizontalAlign="Left"
                                                    Font-Bold="true" ForeColor="Black" />
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                        <NestedViewSettings>
                                            <ParentTableRelation>
                                                <telerik:GridRelationFields DetailKeyField="BucketID" MasterKeyField="BucketID" />
                                            </ParentTableRelation>
                                        </NestedViewSettings>
                                        <NestedViewTemplate>
                                            <table cellpadding="0" cellspacing="0" style="width: 100%; text-align: center; background-color: #CEE3F6;">
                                                <tr valign="top">
                                                    <td valign="top">
                                                        <telerik:RadGrid ID="RadGridCurrencyDetailInner" OnNeedDataSource="RadGridCurrencyDetailInner_NeedDataSource"
                                                            runat="server" AllowSorting="false" AllowPaging="false" ShowStatusBar="true"
                                                            Width="100%">
                                                             <ExportSettings ExportOnlyData="true" OpenInNewWindow="true" />
                                                            <MasterTableView AllowMultiColumnSorting="false" AutoGenerateColumns="false" TableLayout="Fixed"
                                                                AllowFilteringByColumn="false" AllowSorting="false" IsFilterItemExpanded="false"
                                                                DataKeyNames="BucketId">
                                                                <Columns>
                                                                    <telerik:GridBoundColumn AllowFiltering="false" DataField="KeyValue" FilterControlAltText="Filter KeyValue column"
                                                                        HeaderText="KeyValue" UniqueName="KeyValue" Display="false">
                                                                        <ItemStyle />
                                                                        <HeaderStyle  />
                                                                    </telerik:GridBoundColumn>
                                                                    <telerik:GridTemplateColumn AllowFiltering="false" DataField="Activities" FilterControlAltText="Filter Activities column"
                                                                        HeaderText="Activities" UniqueName="Activities">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblActivities" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Activities")%>'></asp:Label>
                                                                            &nbsp;
                                                                <asp:HyperLink ID="hypVarianceManagement" CssClass="SlimItem" runat="server" Target="_self"
                                                                    ForeColor="blue" Visible="false">[ Variance Management ]</asp:HyperLink>
                                                                            &nbsp;
                                                                <asp:HyperLink ID="HypHoldingsNPV" CssClass="SlimItem" runat="server" Target="_self"
                                                                    ForeColor="blue" Visible="false">[ Holdings / NPV ]</asp:HyperLink>
                                                                            &nbsp;
                                                                <asp:Image ID="AttentionImage" runat="server" Visible="False" />
                                                                        </ItemTemplate>
                                                                        <ItemStyle HorizontalAlign="Left" CssClass="SlimCell" Wrap="false" />
                                                                        <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                                            HorizontalAlign="Left" Width="25%" />
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn DataField="Broker" DataType="System.Decimal" FilterControlAltText="Filter Broker column"
                                                                        UniqueName="BrokerValue" HeaderText="Broker">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblBroker" runat="server" Text='<%# SetText(Eval("KeyValue"), Eval("BrokerValue")) %>'></asp:Label><%--C1---%>
                                                                        </ItemTemplate>
                                                                        <ItemStyle HorizontalAlign="Right" CssClass="SlimCell" Wrap="false" />
                                                                        <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                                            HorizontalAlign="Left" Width="25%" />
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn DataField="System" DataType="System.Decimal" FilterControlAltText="Filter System column"
                                                                        HeaderText="System" UniqueName="SystemValue">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblSystem" runat="server" Text='<%# SetText(Eval("KeyValue"), Eval("SystemValue")) %>'
                                                                                Visible='<%# SetVisibility(Eval("KeyValue")) %>'></asp:Label>
                                                                            <%--C1---%>
                                                                        </ItemTemplate>
                                                                        <ItemStyle HorizontalAlign="Right" CssClass="SlimCell" Wrap="false" />
                                                                        <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                                            HorizontalAlign="Left" Width="25%" />
                                                                    </telerik:GridTemplateColumn>
                                                                    <telerik:GridTemplateColumn DataType="System.Decimal" HeaderText="Difference" UniqueName="VarDifference">
                                                                        <ItemTemplate>
                                                                            <asp:Label ID="lblDifference" runat="server" Text='<%# SetText(Eval("KeyValue"), Eval("VarDifference")) %>'
                                                                                Visible='<%# SetVisibility(Eval("KeyValue")) %>'></asp:Label>
                                                                            <%--C1---%>
                                                                        </ItemTemplate>
                                                                        <ItemStyle HorizontalAlign="Right" CssClass="SlimCell" Wrap="false" />
                                                                        <HeaderStyle CssClass="OTCs_gridHeader_left" ForeColor="Black" Font-Bold="true"
                                                                            HorizontalAlign="Left" Width="25%" />
                                                                    </telerik:GridTemplateColumn>
                                                                </Columns>
                                                            </MasterTableView>
                                                        </telerik:RadGrid>
                                                    </td>
                                                </tr>
                                            </table>
                                        </NestedViewTemplate>
                                    </MasterTableView>
                                    <HeaderStyle Font-Bold="true" HorizontalAlign="Center" />
                                </telerik:RadGrid>
VB
Protected Sub rtbOTCCurrencyDetails_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs)
        Dim ExStruct As Telerik.Web.UI.ExportInfrastructure.ExportStructure = Nothing
        Dim renderer As Telerik.Web.UI.ExportInfrastructure.XlsBiffRenderer = Nothing
        Dim renderedBytes As Byte() = Nothing

        Try
            
            'RadGridCurrencyDetail.ExportSettings.ExportOnlyData = True
            RadGridCurrencyDetail.ExportSettings.IgnorePaging = True
            RadGridCurrencyDetail.ExportSettings.OpenInNewWindow = True
            RadGridCurrencyDetail.ExportSettings.FileName = "fileName"
            RadGridCurrencyDetail.ExportSettings.Excel.Format = GridExcelExportFormat.Html
            RadGridCurrencyDetail.ExportSettings.HideStructureColumns = True
            RadGridCurrencyDetail.MasterTableView.ExportToExcel()
        Catch
            Throw
        End Try

    End Sub


Please do the neddful for same.

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 24 Aug 2016, 02:34 PM
Hi Swapnil,

I revise the provided result screenshot but was not able to observe the exact alignment problem you are talking about. Can you please elaborate on the exact issue you are facing and what the expected result is so that we can further assists?

Regards,
Maria Ilieva
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Swapnil
Top achievements
Rank 1
answered on 25 Aug 2016, 06:12 AM

Hi Maria,

Thanks for the reply. Sorry for confusion there is no alignment issue. Actually there is issue like extra cells added  in Parent table while exporting to excel.

Please find attached image Actual result and Expected result screen shot.

0
Swapnil
Top achievements
Rank 1
answered on 25 Aug 2016, 06:13 AM

Hi Maria,

Thanks for the reply. Sorry for confusion there is no alignment issue. Actually there is issue like extra cells added  in Parent table while exporting to excel.

Please find attached image Actual result and Expected result screen shot.

0
Pavlina
Telerik team
answered on 29 Aug 2016, 09:13 PM
Hello,

I tried to replicate the problem with empty cells using the provided code, but to no avail. You can find attached my test page, give it a try and see what is the difference on your end.

Regards,
Pavlina
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Swapnil
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Swapnil
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or