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

Excel Export Column Widths with header title

1 Answer 283 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 18 May 2011, 02:29 PM
I am trying to have the Excel export of my grid show the title from the header without expanding the first column of the data.
See attached screenshot

It is making my ID column very wide even though the column itself in the grid is defined to be narrow. 
Is there anyway for my header title to appear in the export but not cause that first real data column to be so wide?
It does seem to work in the PDF because the PDF won't show my header title - I have only been able to show it as a Title of the page and not as an item in the grid header (which is a seperate issue).

The following is the code that I have tried to use to suggest that the title row should take two columns instead of just one.
I've set the title cell to use colspan="2" hoping that would transfer into the Excel file... but no luck as you can see.

<MasterTableView DataKeyNames="Id" DataSourceID="ClientDataSource" EditMode="PopUp"
                CommandItemDisplay="Top" HeaderStyle-CssClass="grid_header">
                <CommandItemTemplate>
                    <table width="100%">
                        <colgroup>
                            <col width="35px" />
                            <col />
                            <col />
                            <col />
                        </colgroup>
                        <tr>
                            <td colspan="2" style="font-size: 13px; padding: 10px 10px; text-align: left; white-space: nowrap; font-weight: bold">
                                <asp:Label runat="server" ID="lbl_reportName" Text="none">Client List</asp:Label>
                            </td>
                            <td class="flow_no_print">
                                <telerik:RadButton ID="btnAddNewClient" runat="server" ButtonType="LinkButton" BorderStyle="None" AutoPostBack="true"
                                    CommandName="InitInsert" Text="Add Client">
                                    <Icon PrimaryIconCssClass="rbAdd" PrimaryIconLeft="4" PrimaryIconTop="4" />
                                </telerik:RadButton>
  
                            </td>
                            <td class="flow_no_print" style="width: 160px; text-align: right;">
                                <asp:ImageButton Height="32" ID="ExportToPdfButton" CommandName="ExportToPdf" ImageUrl="~/images/icons/pdf.png" runat="server" ToolTip="Export to PDF" AlternateText="Export to PDF" /> 
                                <asp:ImageButton Height="32" ID="ExportToExcelButton" CommandName="ExportToExcel" ImageUrl="~/images/icons/excel.png"  runat="server" ToolTip="Export to Excel"  AlternateText="Export to Excel" /> 
                                <asp:ImageButton Height="32" ID="ExportToWordButton" CommandName="ExportToWord" ImageUrl="~/images/icons/word.png" runat="server" ToolTip="Export to Word" AlternateText="Export to Word" /> 
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 35px;"></td>
                            <td></td>
                            <td></td>
                            <td></td>
                        </tr>
                    </table>
                </CommandItemTemplate>
                <Columns>
                    <telerik:GridEditCommandColumn UniqueName="EditColumn" ButtonType="ImageButton">
                    <ItemStyle Width="20" />
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="ID" SortExpression="Id"
                        UniqueName="Id" Visible="true" ReadOnly="true">
                        <ItemStyle Width="35px" />
                        <HeaderStyle width="35px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Name" HeaderText="Name" MaxLength="45" SortExpression="Name"
                        UniqueName="Name">
                        <ItemStyle Width="260px" />
                        <HeaderStyle width="260px" />
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn HeaderText="Active" SortExpression="Active" UniqueName="ActiveMark" ReadOnly="true">
                       <ItemTemplate>
                       <%# ShowActiveInd(DataBinder.Eval(Container.DataItem, "Active"))%>
                       </ItemTemplate>
                       <ItemStyle Width="20px" HorizontalAlign="Left" />
                       <HeaderStyle width="200px" />
                    </telerik:GridTemplateColumn>
                    <telerik:GridCheckBoxColumn DataField="Active" DataType="System.Boolean" HeaderText="Active"
                        SortExpression="Active" UniqueName="Active" ReadOnly="false" Display="false" DefaultInsertValue="true" >
                    </telerik:GridCheckBoxColumn>
                    <telerik:GridButtonColumn ButtonType="ImageButton" UniqueName="ActiveColumn" HeaderText="Active" Display="false">
                        <ItemStyle HorizontalAlign="Left" />
                    </telerik:GridButtonColumn>
                </Columns>


Thanks for your help,

Jonathan

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 May 2011, 03:14 PM
Hello Jonathan,

Please review the following help topic for more information of RadGrid export styling.

Regards,
Princy.
Tags
Grid
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or