Good morning ,
I have a datagrid in my project and for some reason one column does not exporting to excel spreadhseet.
The column name is called 'Location'
Please see my html:
telerik:RadGrid ID="EmplReqGrid" runat="server" Skin="Simple"
GridLines="None" AllowPaging="true" AllowSorting="true"
onexcelmlexportrowcreated="EmplReqGrid_ExcelMLExportRowCreated"
onexcelmlexportstylescreated="EmplReqGrid_ExcelMLExportStylesCreated"
onitemcommand="EmplReqGrid_ItemCommand" onitemcreated="EmplReqGrid_ItemCreated"
onitemdatabound="EmplReqGrid_ItemDataBound"
onneeddatasource="EmplReqGrid_NeedDataSource"
onpageindexchanged="EmplReqGrid_PageIndexChanged"
onpagesizechanged="EmplReqGrid_PageSizeChanged"
onpdfexporting="EmplReqGrid_PdfExporting"
onsortcommand="EmplReqGrid_SortCommand" >
<ExportSettings FileName="EmplReqRpt" OpenInNewWindow="true" IgnorePaging="true" ExportOnlyData="true">
<Excel Format="ExcelML" FileExtension="xls"/>
<Pdf FontType="Subset" PaperSize="letter" />
</ExportSettings>
<MasterTableView AutoGenerateColumns="false" AllowMultiColumnSorting="true" >
<HeaderStyle Font-Names="Arial" BackColor="#3974AE" ForeColor="White" Font-Size="Small" />
<Columns>
<telerik:GridBoundColumn HeaderText="Eis-Id" DataField="PRI" UniqueName="PRI" ReadOnly="True" SortExpression="PRI" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Name" DataField="NAME" UniqueName="NAME" Display="false" ></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="ReqNo" DataField="TRKNO" UniqueName="TRKNO" ReadOnly="True" SortExpression="TRKNO" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Job" DataField="JOB" UniqueName="JOB" ReadOnly="True" SortExpression="JOB" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Location" DataField="LOC" UniqueName="LOC" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ReadOnly="true" SortExpression="LOC" >
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Term" DataField="TERMID" UniqueName="TERMID" ReadOnly="True" SortExpression="TERMID" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Start Date" DataField="TERMST" UniqueName="TERMST" ReadOnly="true" DataFormatString="{0:MM/dd/yyyy}" SortExpression="TERMST" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="End Date" DataField="TERMEND" UniqueName="TERMEND" ReadOnly="true" DataFormatString="{0:MM/dd/yyyy}" SortExpression="TERMEND" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="No of Days" DataField="NUMP" UniqueName="NUMP" ReadOnly="True" SortExpression="NUMP" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Process Status" DataField="APPRFLAG" UniqueName="APPRFLAG" ReadOnly="True" SortExpression="APPRFLAG" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Rec Status" DataField="STATUS" UniqueName="STATUS" ReadOnly="True" SortExpression="STATUS" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Process Status Date" DataField="FORMDATE" UniqueName="FORMDATE" ReadOnly="True" DataFormatString="{0:MM/dd/yyyy}" SortExpression="FORMDATE" HeaderButtonType="TextButton" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="REQFLAG" UniqueName="REQFLAG" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SENDFLAG" UniqueName="SENDFLAG" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BEG_FALL" UniqueName="BEG_FALL" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="END_FALL" UniqueName="END_FALL" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BEG_SPRING" UniqueName="BEG_SPRING" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="END_SPRING" UniqueName="END_SPRING" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="BEG_ALL" UniqueName="BEG_ALL" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="END_ALL" UniqueName="END_ALL" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="TRKSEQ" UniqueName="TRKSEQ" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="FLAG" UniqueName="FLAG" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="SCHEDULE" UniqueName="SCHEDULE" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="UPDFLAG " UniqueName="UPDFLAG" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="GALFLAG" UniqueName="GALFLAG" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="LIC_DESCR" UniqueName="LIC_DESCR" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="HSIND" UniqueName="HSIND" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="CFN" UniqueName="CFN" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="APPRNAME" UniqueName="APPRNAME" Display="false"></telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="APPREMAIL" UniqueName="APPREMAIL" Display="false"></telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText="Link to Form" UniqueName="ButtonColumn" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="150px" >
<ItemTemplate>
<asp:ImageButton ID="ReqFormBtn" ImageUrl="~/Image/update.jpg"
BackColor="#5A8EC1"
ToolTip="update,re-submit or print the request" runat="server" CommandName="Redirect" Width="18px" Height="18px" Visible="false" />
<asp:ImageButton ID="ApprFormBtn" ImageUrl="~/Image/Appr_Button.jpg" BackColor="#5A8EC1"
ToolTip="approve/disapprove request" runat="server" CommandName="Approve" Width="18px" Height="18px" ImageAlign="TextTop" Visible="false" />
<asp:Image ID="Image1" runat="server" ToolTip="HR REQUEST" ImageUrl="~/Image/HR_Request3.jpg" Width="12px" Height="12px" Visible="false" />
<%--<asp:ImageButton ID="CancelReqBtn" ImageUrl="~/Image/Cancel_button6.png" runat="server" CommandName="Cancel" ImageAlign="Right" BackColor="Transparent" ToolTip="cancel the request" Width="50px" Height="20px" Visible="false" OnClientClick="ConfirmCancel(value);" />--%>
<asp:ImageButton ID="GalaxyGBtn" runat="server" ImageUrl="~/Image/Galaxy.png" Width="18px" Height="18px" BackColor="#BDCBDE" ToolTip="galaxy generated/updated request" CommandName="GalaxyRequest" Visible="false" />
<asp:ImageButton ID="PlaceHolderBtn" runat="server" ImageUrl="~/Image/PlaceHolder.jpg" Width="17px" Height="17px" ToolTip="placeholder must be budgeted" Visible="false" BackColor="#BDCBDE" CommandName="PlaceHolderRequest" />
<asp:ImageButton ID="HistoryBtn" runat="server" ImageUrl="~/Image/HistoryReq.png" Width="20px" Height="20px" ToolTip="Archive" BackColor="#BDCBDE" Visible="false" CommandName="HistoryRequest" />
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick = "false">
<Selecting AllowRowSelect="false" />
</ClientSettings>
</telerik:RadGrid>
And here is event which do exporting:
protected void ExporttoExcel_Click1(object sender, ImageClickEventArgs e)
{
try
{
if (!IsPostBack)
return;
RadGrid ReqInfoGrid = (RadGrid)EmpReqReport.FindItemByValue("EmployeeData").FindControl("EmplReqGrid");
ReqInfoGrid.DataSource = Session["dtGrid"];
ReqInfoGrid.DataBind();
ReqInfoGrid.MasterTableView.GetColumn("NAME").Display = true;
ReqInfoGrid.MasterTableView.ExportToExcel();
}
catch (Exception ex)
{
throw;
}
}
Please help me to resolve this issue.
thanks.
Vitaly.