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

Grid Exporting

3 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
New User
Top achievements
Rank 1
New User asked on 22 Jul 2011, 08:33 PM
My grid is exporting but the format is not acceptable.  I really want the export to put each column in the grid is 1 separate column in the export and I'm having a problem.  Here is the sample of my grid.

<

 

telerik:RadGrid ID="grdCurrentandPrior" runat="server" AllowSorting="True" AutoGenerateColumns="False"

 

 

GridLines="None" Skin="Web20" Style="margin-right: 0px" Width="673px" Height="260px"

 

 

OnNeedDataSource="grdCurrentandPrior_NeedDataSource" OnItemDataBound="grdCurrentandPrior_ItemDataBound">

 

 

<ExportSettings FileName="OpenItemsCurrentInventory" IgnorePaging="True" OpenInNewWindow="True">

 

 

<Excel Format="HTML" />

 

 

</ExportSettings>

 

 

<MasterTableView CommandItemDisplay="Bottom" AllowNaturalSort="false">

 

 

<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false"/>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn HeaderText="Assignee" UniqueName="Assignee" SortExpression="Assignee">

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" />

 

 

<ItemTemplate>

 

 

<asp:Label ID="lbAssignee" runat="server" Text='<%# Eval("Assignee") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Jurisdictions" UniqueName="JurisdictionCount" SortExpression="JurisdictionCount">

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" />

 

 

<ItemTemplate >

 

 

<asp:Label ID="lbJurisdiction" runat="server" Text='<%# Eval("JurisdictionCount") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn UniqueName="TemplateColumn">

 

 

<HeaderTemplate>

 

 

<table id="Table1" cellspacing="1" cellpadding="1" width="200px" border="1">

 

 

<tr>

 

 

<td colspan="2" align="center">

 

 

<b>Open Items by Age</b>

 

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td align="center" width="50%">

 

 

<b>Prior</b>

 

 

</td>

 

 

<td align="center" width="50%">

 

 

<b>Current</b>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</HeaderTemplate>

 

 

<ItemTemplate>

 

 

<table id="Table2" cellspacing="1" cellpadding="1" width="260px" border="1">

 

 

<tr>

 

 

<td width="50%">

 

 

<asp:Label ID="lblPriorCount" runat="server" Text='<%# Eval("OpenItemsCountPrior") %>'></asp:Label>

 

 

</td>

 

 

<td width="50%">

 

 

<asp:Label ID="lblCurrentCount" runat="server" Text='<%# Eval("OpenItemsCountELD") %>'></asp:Label>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</ItemTemplate>

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="Items Left to Pay" UniqueName="TotalRemainingItems" SortExpression="TotalRemainingItems">

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" />

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblPctComplete" runat="server" Text='<%# Eval("TotalRemainingItems") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="% Complete" UniqueName="clmPctComplete">

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" />

 

 

<ItemTemplate>

 

 

<asp:Label ID="lblPctComplete" runat="server" Text='<%# Eval("TotalRemainingItems") %>'></asp:Label>

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridBoundColumn DataField="AssigneeEmployeeKey" ReadOnly="True" UniqueName="AssigneeEmployeeKey"

 

 

Visible="False">

 

 

</telerik:GridBoundColumn>

 

 

</Columns>

 

 

</MasterTableView>

 

 

<HeaderStyle BorderStyle="Solid" />

 

 

 

<ClientSettings>

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

</ClientSettings>

 

 

</telerik:RadGrid>

 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 25 Jul 2011, 05:19 AM
Hello,

Try setting the ExportSettings as shown below.

aspx:
<ExportSettings IgnorePaging="true" Excel-Format="ExcelML" ExportOnlyData="true">
</ExportSettings>

Thanks,
Princy
0
New User
Top achievements
Rank 1
answered on 01 Aug 2011, 09:22 PM
Princey,

When I have those settings set

Format

 

="ExcelML"  and

 

ExportOnlyData

 

="true"

 


No Data at all comes thru to my excel file.  Could it have anything to do with the fact they are in GridTemplateColumns?

 

 

<telerik:RadGrid ID="grdCurrentandPrior" runat="server" AllowSorting="True" AutoGenerateColumns="False"

 

 

 

 

 

 

GridLines="Horizontal" Skin="Web20" Style="margin-right: 0px" Width="780px" Height="265px"

 

 

 

 

 

 

OnNeedDataSource="grdCurrentandPrior_NeedDataSource" OnExcelMLExportRowCreated="grdCurrentandPrior_ExcelMLExportRowCreated">

 

 

 

 

 

 

<ExportSettings FileName="OpenItemsCurrentInventory" IgnorePaging="True" OpenInNewWindow="True"

 

 

 

 

 

 

ExportOnlyData="true" >

 

 

 

 

 

 

<Excel Format="ExcelML" />

 

 

 

 

 

 

</ExportSettings>

 

 

 

 

 

 

<MasterTableView CommandItemDisplay="Bottom" AllowNaturalSort="false" ShowFooter="false">

 

 

 

 

 

 

<CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false"

 

 

 

 

 

 

ShowRefreshButton="false" />

 

 

 

 

 

 

<Columns>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Assignee" UniqueName="Assignee" SortExpression="Assignee">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="150px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lbAssignee" runat="server" Text='<%# Eval("Assignee") %>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="State" UniqueName="State" SortExpression="State"

 

 

 

 

 

 

Visible="false">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="150px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lbState" runat="server" Text='<%# Eval("State") %>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Jurisdictions" UniqueName="JurisdictionCount"

 

 

 

 

 

 

SortExpression="JurisdictionCount">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lbJurisdiction" runat="server" Text='<%# Eval("JurisdictionCount", "{0:N0}")%>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Prior Open Items" UniqueName="OpenItemsCountPrior"

 

 

 

 

 

 

SortExpression="OpenItemsCountPrior">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lbPrior" runat="server" Text='<%# Eval("OpenItemsCountPrior", "{0:N0}") %>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Current Open Items" UniqueName="OpenItemsCountCurrent"

 

 

 

 

 

 

SortExpression="OpenItemsCountCurrent">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="100px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lbCurrent" runat="server" Text='<%# Eval("OpenItemsCountCurrent", "{0:N0}") %>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="Items Left to Pay" UniqueName="TotalRemainingItems"

 

 

 

 

 

 

SortExpression="TotalRemainingItems">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" Width="105px" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lblTotalRemain" runat="server" Text='<%# Eval("TotalRemainingItems", "{0:N0}") %>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

 

 

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridTemplateColumn HeaderText="% Complete" UniqueName="clmPctComplete" SortExpression="PercentComplete">

 

 

 

 

 

 

<HeaderStyle Font-Bold="True" HorizontalAlign="Center" Font-Names="Arial" />

 

 

 

 

 

 

<ItemTemplate>

 

 

 

 

 

 

<asp:Label ID="lblPctComplete" runat="server" Text='<%# Eval("PercentComplete", "{0:F2}%")%>'></asp:Label>

 

 

 

 

 

 

</ItemTemplate>

 

 

<ItemStyle HorizontalAlign="Right" ForeColor="Black" />

 

 

 

 

 

 

<FooterStyle HorizontalAlign="Right" Font-Bold="true" />

 

 

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

 

<telerik:GridBoundColumn DataField="AssigneeEmployeeKey" ReadOnly="True" UniqueName="AssigneeEmployeeKey"

 

 

 

 

 

 

Visible="False">

 

 

 

 

 

 

</telerik:GridBoundColumn>

 

 

 

 

 

 

</Columns>

 

 

 

 

 

 

</MasterTableView>

 

 

 

 

 

 

<HeaderStyle BorderStyle="Solid" />

 

 

 

 

 

 

<ClientSettings>

 

 

 

 

 

 

<Scrolling AllowScroll="True" UseStaticHeaders="True" />

 

 

 

 

 

 

</ClientSettings>

 

 

 

 

 

 

</telerik:RadGrid>

 

0
Accepted
Princy
Top achievements
Rank 2
answered on 02 Aug 2011, 06:17 AM
Hello,

I cannot reproduce the issue at my end. Here is the sample code that I tried which exported GridTemplateColumns as well

aspx:
<telerik:RadGrid runat="server" ID="RadGrid2" AutoGenerateColumns="False"
            AutoGenerateEditColumn="true"  onneeddatasource="RadGrid2_NeedDataSource">
<ExportSettings IgnorePaging="true" Excel-Format="ExcelML" ExportOnlyData="true">
</ExportSettings>
   <MasterTableView CommandItemDisplay="Bottom" AllowNaturalSort="false">
      <Columns
         <telerik:GridTemplateColumn HeaderText="Assignee" UniqueName="Assignee" SortExpression="Assignee">
           <ItemTemplate>
              <asp:Label ID="lbAssignee" runat="server" Text='<%# Eval("Assignee") %>'></asp:Label>
          </ItemTemplate>
        </telerik:GridTemplateColumn>
     </Columns>
</telerik:RadGrid>

Also check the following help documentation which explains more about this.
ExcelML basics.

Thanks,
Princy.
Tags
Grid
Asked by
New User
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
New User
Top achievements
Rank 1
Share this question
or