Hello,
I have a grid that I am exporting to ExcelML, when I export to standard Excel, all the columns export, but when I choose ML, only one column is exported, the Date Added Column.
Code behind for the export options:
Any thoughts to what might be causing this?
Here is my grid code:
I have a grid that I am exporting to ExcelML, when I export to standard Excel, all the columns export, but when I choose ML, only one column is exported, the Date Added Column.
<telerik:RadGrid ID="gridConditions" runat="server" EnableTheming="False" Skin="WebBlue" AllowPaging="True" AllowSorting="True" GridLines="Both" AutoGenerateColumns="False" OnNeedDataSource="gridConditions_NeedDataSource" PageSize="15" OnItemDataBound="gridConditions_ItemDataBound" ShowGroupPanel="false" AllowFilteringByColumn="false" OnCancelCommand="gridConditions_CancelCommand" OnEditCommand="gridConditions_EditCommand" OnExcelMLExportRowCreated="gridConditions_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="gridConditions_ExcelMLExportStylesCreated" OnItemCommand="gridConditions_ItemCommand"> <PagerStyle Mode="Slider" /> <ExportSettings IgnorePaging="true" OpenInNewWindow="true" FileName="ConditionsExport" ExportOnlyData="true"> <Excel Format="ExcelML" /> </ExportSettings> <MasterTableView NoMasterRecordsText="There are no conditions to display. If you applied filters, you may need to broaden your search." CommandItemDisplay="Bottom"> <CommandItemTemplate> <table width="100%"> <tr> <td align="right"> <asp:Button ID="ExportToExcelButton" runat="server" Width="100%" CommandName="ExportToExcel" Text="Export To Excel" /> </td> </tr> </table> </CommandItemTemplate> <ExpandCollapseColumn Visible="True"> </ExpandCollapseColumn> <Columns> <telerik:GridBoundColumn DataField="ConditionId" SortExpression="ConditionId" UniqueName="ConditionId" Visible="False" /> <telerik:GridTemplateColumn HeaderStyle-Width="100px" HeaderText="Condition ID" SortExpression="ConditionIdentifier" DataField="ConditionIdentifier"> <ItemTemplate> <asp:HyperLink CssClass="ConditionHyperLink" ID="EditLink" runat="server" Text='<%#Eval("ConditionIdentifier") %>'></asp:HyperLink> </ItemTemplate> <HeaderStyle Width="100px"></HeaderStyle> </telerik:GridTemplateColumn> <telerik:GridBoundColumn AllowSorting="False" DataField="Summary" HeaderText="Summary" UniqueName="Summary" FilterControlWidth="200px" /> <telerik:GridBoundColumn DataField="IdentifiedByFullName" HeaderStyle-Width="120px" HeaderText="Identified By" SortExpression="IdentifiedByLastName" UniqueName="IdentifiedByFullName" /> <telerik:GridDateTimeColumn DataField="DateCreated" HeaderStyle-Width="100px" HeaderText="Date Added" SortExpression="DateCreated" UniqueName="DateCreated" DataFormatString="{0:d}" /> <telerik:GridBoundColumn DataField="ConditionStatusName" HeaderStyle-Width="100px" HeaderText="Status" SortExpression="ConditionStatusName" UniqueName="ConditionStatusName" /> <telerik:GridDateTimeColumn DataField="ActualDueDate" HeaderStyle-Width="100px" HeaderText="Due Date" SortExpression="ActualDueDate" UniqueName="ActualDueDate" DataFormatString="{0:d}" EmptyDataText="Not Set" > <ItemStyle Font-Bold="True" ForeColor="Red" /> </telerik:GridDateTimeColumn> <telerik:GridButtonColumn CommandName="Edit" HeaderText="Edit" UniqueName="Edit" HeaderStyle-Width="20px" Text="Edit" ButtonType="ImageButton" ItemStyle-HorizontalAlign="Center"> <ItemStyle HorizontalAlign="Center"></ItemStyle> </telerik:GridButtonColumn> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="false" /> </ClientSettings> </telerik:RadGrid>Code behind for the export options:
bool isConfigured = false; protected void gridConditions_ExcelMLExportRowCreated(object sender, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLRowCreatedArgs e) { if(e.RowType == GridExportExcelMLRowType.HeaderRow) { gridConditions.Rebind(); //workaround to get the template column's content } if (e.RowType == GridExportExcelMLRowType.DataRow) { if (!isConfigured) { //Set Worksheet name e.Worksheet.Name = "Conditions List"; //Set Column widths foreach (ColumnElement column in e.Worksheet.Table.Columns) { if (e.Worksheet.Table.Columns.IndexOf(column) == 2) column.Attributes["ss:Width"] = "180"; //set width 180 to ProductName column else column.Attributes["ss:Width"] = "80"; //set width 80 to the rest of the columns } //Set Page options PageSetupElement pageSetup = e.Worksheet.WorksheetOptions.PageSetup; pageSetup.PageLayoutElement.IsCenteredVertical = true; pageSetup.PageLayoutElement.IsCenteredHorizontal = true; pageSetup.PageMarginsElement.Left = 0.5; pageSetup.PageMarginsElement.Top = 0.5; pageSetup.PageMarginsElement.Right = 0.5; pageSetup.PageMarginsElement.Bottom = 0.5; pageSetup.PageLayoutElement.PageOrientation = PageOrientationType.Landscape; //Freeze panes e.Worksheet.WorksheetOptions.AllowFreezePanes = true; e.Worksheet.WorksheetOptions.LeftColumnRightPaneNumber = 1; e.Worksheet.WorksheetOptions.TopRowBottomPaneNumber = 1; e.Worksheet.WorksheetOptions.SplitHorizontalOffset = 1; e.Worksheet.WorksheetOptions.SplitVerticalOffest = 1; isConfigured = true; } } } protected void gridConditions_ExcelMLExportStylesCreated(object sender, Telerik.Web.UI.GridExcelBuilder.GridExportExcelMLStyleCreatedArgs e) { //Apply background colors foreach (StyleElement style in e.Styles) { if (style.Id == "headerStyle") { style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.Gray; } if (style.Id == "alternatingItemStyle") { style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.LightGray; } if (style.Id.Contains("itemStyle")) { style.InteriorStyle.Pattern = InteriorPatternType.Solid; style.InteriorStyle.Color = System.Drawing.Color.White; } } }Any thoughts to what might be causing this?
Here is my grid code: