Hi below is my aspx and aspx.cs file , I am trying to export all data(MasterTableView and DetailsTableView), But my excel file has an icon in excel sheet
Attached is the screenshot of the icon and excel file,
please help me out.
<script type="text/javascript" language="javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportMasterDataButton") > 0) {
args.set_enableAjax(false);
}
if (args.get_eventTarget().indexOf("ExportDetailDataButton") > 0) {
args.set_enableAjax(false);
}
if (args.get_eventTarget().indexOf("ExportMasterGridButton") > 0) {
args.set_enableAjax(false);
}
}
</script>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="GridView12">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="GridView12" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="GridView12" runat="server" Width="100%" AutoGenerateColumns="false"
PageSize="10" EnableLinqExpressions="false" AllowSorting="True" AllowFilteringByColumn="True"
OnDetailTableDataBind="GridView12_DetailTableDataBind" enablelinqexpression="false"
AllowPaging="True" CellSpacing="1" Style="padding: 1px;" Skin="Default" OnNeedDataSource="GridView12_OnNeedDataSource"
OnPreRender="GridView12_PreRender" OnItemCreated="GridView12_OnItemCreated" OnItemCommand="GridView12_OnItemCommand">
<ClientSettings>
<Selecting AllowRowSelect="False" />
<Scrolling AllowScroll="true" ScrollHeight="400px" UseStaticHeaders="true" />
</ClientSettings>
<ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
</ExportSettings>
<MasterTableView Name="TypeSummary" DataKeyNames="type_id" ClientDataKeyNames="type_id"
NoMasterRecordsText="<center>No viewings are available" CommandItemDisplay="Top">
<HeaderStyle Font-Size="14px" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" />
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" />
<SortExpressions>
<telerik:GridSortExpression FieldName="Type_Name" SortOrder="Ascending" />
</SortExpressions>
<CommandItemTemplate>
<asp:Button ID="ExportMasterDataButton" runat="server" CommandName="ExportMasterData"
ClientIDMode="Static"></asp:Button>
<asp:Button ID="ExportMasterGridButton" runat="server" ClientIDMode="Static" CommandName="ExportAllMasterDetailsData" />
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="Type_Name" SortExpression="Type_Name" HeaderText="Type Name"
HeaderButtonType="None" UniqueName="TypeName" ItemStyle-Width="100px" ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Total_Duration" SortExpression="Total_Duration"
HeaderText="Total Duration" UniqueName="TotalDuration" ItemStyle-Width="100px"
ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Num_Contacts" SortExpression="Num_Contacts" HeaderText="Num Contacts"
UniqueName="NumContacts" ItemStyle-Width="100px" ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Virtual_Num_contacts" SortExpression="Virtual_Num_contacts"
ShowSortIcon="true" HeaderText="Num Group Contacts" UniqueName="NumGroupContacts"
ItemStyle-Width="100px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Average_Duration" SortExpression="Average_Duration"
HeaderText="Average Duration" UniqueName="AverageDuration" ShowSortIcon="true"
ItemStyle-Width="100px">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Name="TypeList" DataKeyNames="type_id" Width="100%" Height="100%"
NoDetailRecordsText="<center>No viewings are available</center>" AllowFilteringByColumn="true"
ShowHeadersWhenNoRecords="true" AllowPaging="true" AllowSorting="true" PageSize="10"
CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand">
<HeaderStyle Font-Size="14px" />
<SortExpressions>
<telerik:GridSortExpression FieldName="Access_Date" SortOrder="Ascending" />
</SortExpressions>
<CommandItemTemplate>
<asp:Button ID="ExportDetailDataButton" runat="server" CommandName="ExportDetailsData"
ClientIDMode="Static"></asp:Button>
</CommandItemTemplate>
<Columns>
<telerik:GridDateTimeColumn FilterControlWidth="175px" DataField="Access_Date" HeaderText="Date of Viewing"
SortExpression="Access_Date" UniqueName="AccessDate" PickerType="DateTimePicker"
DataFormatString="{0:MM/dd/yyyy hh:mm tt}" ShowFilterIcon="True" ShowSortIcon="True"
DataType="System.DateTime" AllowFiltering="true">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="First_Name" SortExpression="First_Name" HeaderText="First Name"
HeaderButtonType="None" UniqueName="FirstName" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Last_Name" SortExpression="Last_Name" HeaderText="Last Name"
HeaderButtonType="None" UniqueName="LastName" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Email_Address" HeaderText="Email Address" ItemStyle-Width="100px" FilterControlWidth="100px"
SortExpression="Email_Address" UniqueName="EmailAddress" ShowSortIcon="true" AllowFiltering="true">
<ItemTemplate>
<a onclick="viewVirtualContact(<%#Eval("contact_id")%>,<%#Eval("isvirtualcontact")%>)">
<%# Eval("Email_Address") %></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Business_title" SortExpression="Business_title"
HeaderText="Title" HeaderButtonType="None" UniqueName="Title" ItemStyle-Width="100px"
FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="city" SortExpression="city" HeaderText="City"
HeaderButtonType="None" UniqueName="City" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="state" SortExpression="state" HeaderText="State"
HeaderButtonType="None" UniqueName="state" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="country" SortExpression="country" HeaderText="Country"
HeaderButtonType="None" UniqueName="country" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Video_Event_Name" SortExpression="Video_Event_Name"
HeaderText="Video Event Name" HeaderButtonType="None" UniqueName="VideoEventName"
ItemStyle-Width="100px" FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Video_Viewed" SortExpression="Video_Viewed" HeaderText="Session Viewed"
HeaderButtonType="None" UniqueName="VideoViewed" ItemStyle-Width="150px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Duration" SortExpression="Duration" HeaderText="Duration"
HeaderButtonType="None" UniqueName="Duration" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Sales_Status" SortExpression="Sales_Status" HeaderText="Sales Status"
HeaderButtonType="None" UniqueName="SalesStatus" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ProspectValue" SortExpression="ProspectValue"
HeaderText="Prospect Value" HeaderButtonType="None" UniqueName="ProspectValue"
ItemStyle-Width="100px" FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="iplocation" SortExpression="iplocation" HeaderText="Location"
HeaderButtonType="None" UniqueName="iplocation" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
</Columns>
<PagerStyle AlwaysVisible="true" PageSizeControlType="RadDropDownList" />
</telerik:GridTableView>
</DetailTables>
<PagerStyle AlwaysVisible="true" PageSizeControlType="RadDropDownList" />
</MasterTableView>
<FilterMenu EnableImageSprites="False" />
</telerik:RadGrid>
Below is the code snippet in my aspx.cs file
GridView12.ExportSettings.FileName = "AllDetails";
GridView12.MasterTableView.UseAllDataFields = true;
GridView12.MasterTableView.HierarchyDefaultExpanded = true;
GridView12.MasterTableView.ExportToExcel();
HTML is the excel format of export
GridView12.ExportSettings.FileName = "AllDetails";
GridView12.MasterTableView.UseAllDataFields = true;
GridView12.MasterTableView.HierarchyDefaultExpanded = true;
GridView12.MasterTableView.ExportToExcel();
Attached is the screenshot of the icon and excel file,
please help me out.
<script type="text/javascript" language="javascript">
function onRequestStart(sender, args) {
if (args.get_eventTarget().indexOf("ExportMasterDataButton") > 0) {
args.set_enableAjax(false);
}
if (args.get_eventTarget().indexOf("ExportDetailDataButton") > 0) {
args.set_enableAjax(false);
}
if (args.get_eventTarget().indexOf("ExportMasterGridButton") > 0) {
args.set_enableAjax(false);
}
}
</script>
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<ClientEvents OnRequestStart="onRequestStart"></ClientEvents>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="GridView12">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="GridView12" LoadingPanelID="RadAjaxLoadingPanel1">
</telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="GridView12" runat="server" Width="100%" AutoGenerateColumns="false"
PageSize="10" EnableLinqExpressions="false" AllowSorting="True" AllowFilteringByColumn="True"
OnDetailTableDataBind="GridView12_DetailTableDataBind" enablelinqexpression="false"
AllowPaging="True" CellSpacing="1" Style="padding: 1px;" Skin="Default" OnNeedDataSource="GridView12_OnNeedDataSource"
OnPreRender="GridView12_PreRender" OnItemCreated="GridView12_OnItemCreated" OnItemCommand="GridView12_OnItemCommand">
<ClientSettings>
<Selecting AllowRowSelect="False" />
<Scrolling AllowScroll="true" ScrollHeight="400px" UseStaticHeaders="true" />
</ClientSettings>
<ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
</ExportSettings>
<MasterTableView Name="TypeSummary" DataKeyNames="type_id" ClientDataKeyNames="type_id"
NoMasterRecordsText="<center>No viewings are available" CommandItemDisplay="Top">
<HeaderStyle Font-Size="14px" />
<RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" />
<ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" />
<SortExpressions>
<telerik:GridSortExpression FieldName="Type_Name" SortOrder="Ascending" />
</SortExpressions>
<CommandItemTemplate>
<asp:Button ID="ExportMasterDataButton" runat="server" CommandName="ExportMasterData"
ClientIDMode="Static"></asp:Button>
<asp:Button ID="ExportMasterGridButton" runat="server" ClientIDMode="Static" CommandName="ExportAllMasterDetailsData" />
</CommandItemTemplate>
<Columns>
<telerik:GridBoundColumn DataField="Type_Name" SortExpression="Type_Name" HeaderText="Type Name"
HeaderButtonType="None" UniqueName="TypeName" ItemStyle-Width="100px" ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Total_Duration" SortExpression="Total_Duration"
HeaderText="Total Duration" UniqueName="TotalDuration" ItemStyle-Width="100px"
ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Num_Contacts" SortExpression="Num_Contacts" HeaderText="Num Contacts"
UniqueName="NumContacts" ItemStyle-Width="100px" ShowSortIcon="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Virtual_Num_contacts" SortExpression="Virtual_Num_contacts"
ShowSortIcon="true" HeaderText="Num Group Contacts" UniqueName="NumGroupContacts"
ItemStyle-Width="100px">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Average_Duration" SortExpression="Average_Duration"
HeaderText="Average Duration" UniqueName="AverageDuration" ShowSortIcon="true"
ItemStyle-Width="100px">
</telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView Name="TypeList" DataKeyNames="type_id" Width="100%" Height="100%"
NoDetailRecordsText="<center>No viewings are available</center>" AllowFilteringByColumn="true"
ShowHeadersWhenNoRecords="true" AllowPaging="true" AllowSorting="true" PageSize="10"
CommandItemDisplay="Top" HierarchyLoadMode="ServerOnDemand">
<HeaderStyle Font-Size="14px" />
<SortExpressions>
<telerik:GridSortExpression FieldName="Access_Date" SortOrder="Ascending" />
</SortExpressions>
<CommandItemTemplate>
<asp:Button ID="ExportDetailDataButton" runat="server" CommandName="ExportDetailsData"
ClientIDMode="Static"></asp:Button>
</CommandItemTemplate>
<Columns>
<telerik:GridDateTimeColumn FilterControlWidth="175px" DataField="Access_Date" HeaderText="Date of Viewing"
SortExpression="Access_Date" UniqueName="AccessDate" PickerType="DateTimePicker"
DataFormatString="{0:MM/dd/yyyy hh:mm tt}" ShowFilterIcon="True" ShowSortIcon="True"
DataType="System.DateTime" AllowFiltering="true">
</telerik:GridDateTimeColumn>
<telerik:GridBoundColumn DataField="First_Name" SortExpression="First_Name" HeaderText="First Name"
HeaderButtonType="None" UniqueName="FirstName" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Last_Name" SortExpression="Last_Name" HeaderText="Last Name"
HeaderButtonType="None" UniqueName="LastName" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn DataField="Email_Address" HeaderText="Email Address" ItemStyle-Width="100px" FilterControlWidth="100px"
SortExpression="Email_Address" UniqueName="EmailAddress" ShowSortIcon="true" AllowFiltering="true">
<ItemTemplate>
<a onclick="viewVirtualContact(<%#Eval("contact_id")%>,<%#Eval("isvirtualcontact")%>)">
<%# Eval("Email_Address") %></a>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridBoundColumn DataField="Business_title" SortExpression="Business_title"
HeaderText="Title" HeaderButtonType="None" UniqueName="Title" ItemStyle-Width="100px"
FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="city" SortExpression="city" HeaderText="City"
HeaderButtonType="None" UniqueName="City" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="state" SortExpression="state" HeaderText="State"
HeaderButtonType="None" UniqueName="state" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="country" SortExpression="country" HeaderText="Country"
HeaderButtonType="None" UniqueName="country" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Video_Event_Name" SortExpression="Video_Event_Name"
HeaderText="Video Event Name" HeaderButtonType="None" UniqueName="VideoEventName"
ItemStyle-Width="100px" FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Video_Viewed" SortExpression="Video_Viewed" HeaderText="Session Viewed"
HeaderButtonType="None" UniqueName="VideoViewed" ItemStyle-Width="150px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Duration" SortExpression="Duration" HeaderText="Duration"
HeaderButtonType="None" UniqueName="Duration" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Sales_Status" SortExpression="Sales_Status" HeaderText="Sales Status"
HeaderButtonType="None" UniqueName="SalesStatus" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="ProspectValue" SortExpression="ProspectValue"
HeaderText="Prospect Value" HeaderButtonType="None" UniqueName="ProspectValue"
ItemStyle-Width="100px" FilterControlWidth="100px" ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="iplocation" SortExpression="iplocation" HeaderText="Location"
HeaderButtonType="None" UniqueName="iplocation" ItemStyle-Width="100px" FilterControlWidth="100px"
ShowSortIcon="true" AllowFiltering="true">
</telerik:GridBoundColumn>
</Columns>
<PagerStyle AlwaysVisible="true" PageSizeControlType="RadDropDownList" />
</telerik:GridTableView>
</DetailTables>
<PagerStyle AlwaysVisible="true" PageSizeControlType="RadDropDownList" />
</MasterTableView>
<FilterMenu EnableImageSprites="False" />
</telerik:RadGrid>
Below is the code snippet in my aspx.cs file
GridView12.ExportSettings.FileName = "AllDetails";
GridView12.MasterTableView.UseAllDataFields = true;
GridView12.MasterTableView.HierarchyDefaultExpanded = true;
GridView12.MasterTableView.ExportToExcel();
HTML is the excel format of export
GridView12.ExportSettings.FileName = "AllDetails";
GridView12.MasterTableView.UseAllDataFields = true;
GridView12.MasterTableView.HierarchyDefaultExpanded = true;
GridView12.MasterTableView.ExportToExcel();