I have a grid with detail tables. I'm trying to Export to Excel. Using Just ExportToExcel works although I get a blank first column But I need to add styling and remove <br> from header text so I thought I'd use ExcelML format. This produces only the data for whichever is the current sort column and notthing else.
The _ExcelML methods are empty so it's not happening because of them.
The initial sort is by Due Date. If I change the sort column, I get that column in the export but nothing else.
This is all I get:
...
Thanks,
Dave
<telerik:RadGrid ID="rgInvoices" runat="server" GridLines="None" AllowPaging="True" |
AllowMultiRowSelection="true" ShowStatusBar="true" AllowSorting="True" AutoGenerateColumns="False" |
GroupingEnabled="False" Skin="CentreTelerikNoSelectStyle" EnableEmbeddedSkins="false" |
OnNeedDataSource="rgInvoices_NeedDataSource" PageSize="10" OnItemCreated="rgInvoices_ItemCreated" |
OnItemDataBound="rgInvoices_ItemDataBound" OnDetailTableDataBind="rgInvoices_DetailTableDataBind" |
HeaderStyle-Font-Bold="true" OnExcelMLExportStylesCreated="RadGrid1_ExcelMLExportStylesCreated" |
OnExcelMLExportRowCreated="RadGrid1_ExcelMLExportRowCreated"> |
<ClientSettings> |
<Selecting AllowRowSelect="True" EnableDragToSelectRows="false" /> |
<ClientEvents OnRowSelecting="CancelNonInputSelect" OnRowDeselecting="CancelNonInputSelect" /> |
</ClientSettings> |
<MasterTableView OverrideDataSourceControlSorting="True" DataKeyNames="PK,InvoiceType,Number,DealerRefNumber,DueDate,OriginalAmount,OpenAmount,TransactionType" |
AllowNaturalSort="false" CommandItemDisplay="Top" CommandItemStyle-Font-Bold="true"> |
<CommandItemTemplate> |
<div style="padding: 5px 20px 5px 5px; text-align: left; float: left"> |
<asp:Label ID="lblSearchResults" class="ReportTitleBold" SkinID="none" runat="server" |
meta:resourcekey="lblInvoices"></asp:Label> |
<CENTRE:CentreImageButton ID="btnAddToSelectedInvoices" runat="server" meta:resourcekey="btnAddToSelectedInvoices" |
CausesValidation="false" OnClick="btnAddToSelectedInvoices_Click"></CENTRE:CentreImageButton> |
<CENTRE:CentreImageButton ID="btnExportAll" runat="server" meta:resourcekey="btnExportAll" OnClick="btnExportAll_Click"></CENTRE:CentreImageButton> |
</div> |
<div style="padding: 5px 5px 5px 0px; float: right; white-space: nowrap"> |
<asp:Label ID="lblTotals" runat="server" meta:resourcekey="lblTotals"></asp:Label> |
<asp:Label ID="lblTotalOpenAmount" runat="server"></asp:Label> </div> |
<div style="clear: both;"></div> |
</CommandItemTemplate> |
<SortExpressions> |
<telerik:GridSortExpression FieldName="DueDate" SortOrder="Ascending" /> |
</SortExpressions> |
<Columns> |
<telerik:GridTemplateColumn HeaderText="<%$ Resources:PaymentHistoryHeader %>" HeaderStyle-HorizontalAlign="Center" |
ItemStyle-HorizontalAlign="Center" UniqueName="PaymentLog"> |
<ItemTemplate> |
<asp:ImageButton ID="btnLog" runat="server" ImageUrl="~/images/magnify.gif" CommandName="PaymentLog" CommandArgument='<%# Eval("Number") %>' /> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
<telerik:GridClientSelectColumn UniqueName="SelectColumn" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" /> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:NumberHeader %>" DataField="Number"></telerik:GridBoundColumn> |
<telerik:GridNumericColumn HeaderText="<%$ Resources:DealerRefNumberHeader %>" DataField="DealerRefNumber"></telerik:GridNumericColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:StatusHeader %>" DataField="Status"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:NameHeader %>" DataField="Name"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:TransactionDateHeader %>" DataField="TransactionDate" |
DataFormatString="{0:d}" DataType="System.DateTime"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:PostedDateHeader %>" DataField="PostedDate" |
DataFormatString="{0:d}" DataType="System.DateTime"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:DueDateHeader %>" DataField="DueDate" |
DataFormatString="{0:d}" DataType="System.DateTime"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:OriginalAmountHeader %>" DataField="OriginalAmount" |
DataFormatString="{0:N}" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn HeaderText="<%$ Resources:OpenAmountHeader %>" DataField="OpenAmount" |
DataFormatString="{0:N}" ItemStyle-HorizontalAlign="Right" HeaderStyle-HorizontalAlign="Right"> |
</telerik:GridBoundColumn> |
</Columns> |
<DetailTables> |
<telerik:GridTableView Width="100%"> |
<Columns> |
<telerik:GridBoundColumn DataField="Field2"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field3"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field4"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field5"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field6"></telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="Field7"></telerik:GridBoundColumn> |
</Columns> |
</telerik:GridTableView> |
</DetailTables> |
</MasterTableView> |
<PagerStyle Mode="NextPrevAndNumeric" PagerTextFormat="<%$ Resources:CommonStrings,RadGridPagerTextFormat %>" /> |
</telerik:RadGrid> |
protected void btnExportAll_Click(object sender, ImageClickEventArgs e) |
{ |
rgInvoices.ExportSettings.ExportOnlyData = true; |
rgInvoices.ExportSettings.IgnorePaging = true; |
rgInvoices.ExportSettings.OpenInNewWindow = true; |
rgInvoices.ExportSettings.FileName = "InvoiceActivity"; |
rgInvoices.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.ExcelML; |
rgInvoices.Columns.FindByUniqueName("PaymentLog").Display = false; |
rgInvoices.Columns.FindByUniqueName("SelectColumn").Display = false; |
rgInvoices.MasterTableView.HierarchyDefaultExpanded = true; |
rgInvoices.Rebind(); |
//foreach (GridItem commandItem in rgInvoices.MasterTableView.GetItems(GridItemType.CommandItem)) |
//{ |
// commandItem.Visible = false; |
//} |
rgInvoices.MasterTableView.ExportToExcel(); |
} |
The _ExcelML methods are empty so it's not happening because of them.
The initial sort is by Due Date. If I change the sort column, I get that column in the export but nothing else.
This is all I get:
Due Date | ||
11/15/2009 0:00 | ||
11/15/2009 0:00 |
Thanks,
Dave