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

RadGrid Excel Export Issue

4 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Leela Prasad
Top achievements
Rank 1
Leela Prasad asked on 18 Jul 2011, 12:48 PM
Hi Telerik Team,
                         We are currently facing issue when exporting data to excel from Rad grid.
When we are trying to export only data the button and template coloumns are not exported. If we are trying to export setting ExportOnlyData=false. Some image are not exported and some unwanted grey blocks are appearing and also some javascript error messages are appearing when user tries to click on any headers or link coloumns.

Please suggest us what can be done to export all the data that is displayed in the grid without any unwanted grey buttons and javascript errors.

Note: We are almost done with our application and we are having 100+ radgrids so we need of a approach which does not create rework of all which we had done till now.

Attached the screenshots of exported excel files.
As i am unable to upload code here. I had uploaded it to my skydrive.
https://skydrive.live.com/redir.aspx?cid=0a806b2ac61695d9&resid=A806B2AC61695D9!1218

Thanks & Regards
Leela Prasad

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Jul 2011, 01:23 PM
Hello Leela,

I cannot reproduce the issue at my end.Here is the sample code that I tried which worked as expected.

aspx:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 <asp:ScriptManager ID="ScriptManager1" runat="server">
 </asp:ScriptManager>
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource">
      <ExportSettings  ExportOnlyData="true" Excel-Format="Html" IgnorePaging="true">
      </ExportSettings>
      <MasterTableView CommandItemDisplay="Top">
          <CommandItemSettings ShowExportToExcelButton="true"  />
                <Columns>
                    <telerik:GridBoundColumn HeaderText="EmployeeID" UniqueName="EmployeeID" DataField="EmployeeID">
                    </telerik:GridBoundColumn>
                    <telerik:GridTemplateColumn>
                        <ItemTemplate>
                           <asp:TextBox ID="text" runat="server" Text='<%#Eval("EmployeeID") %>'></asp:TextBox>
                        </ItemTemplate>
                    </telerik:GridTemplateColumn>
                </Columns>
      </MasterTableView>
</telerik:RadGrid>

Images can not be exported in the resulting excel file. It is a limitation of the Excel that images cannot be placed in an excel cell. Check the following help documentation which explains more about this.
Word/Excel export (HTML-based).

Thanks,
Shinu.
0
Leela Prasad
Top achievements
Rank 1
answered on 18 Jul 2011, 04:32 PM
Hi Shinu,
                we don't need images to be exported but some unwanted grey blocks are appearing,
please find the screenshot ExportOnlyData---False.PNG in my intial post where i marked the areas with red boxes, is there a way we can avoid them.

Or
Is there any chance of including all the coloumns including button and template coloumns when using ExportOnlyData=true

Thanks & Regards
Leela Prasad
0
Leela Prasad
Top achievements
Rank 1
answered on 19 Jul 2011, 04:17 AM
Awaiting for responses
0
Elitsa
Top achievements
Rank 1
answered on 21 Aug 2014, 10:59 AM
Hi Leela,

Setting AlternateText for my images and ExportOnlyData to true works good for me :)

I have:

protected void myRadGrid_OnItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
                var passInfo = (UserPriductsInfo)e.Item.DataItem;
    if (passInfo != null)
    {
        var imgAttemptPassed = (Image) e.Item.FindControl("imgAttemptPassed");

        if (imgAttemptPassed != null)
        {
            if (passInfo.attemptPassed == true)
            {
                            imgAttemptPassed.ImageUrl = "~/Images/tick.png";
                imgAttemptPassed.AlternateText = "Yes";
            }
            else
            {
                            imgAttemptPassed.ImageUrl = "~/Images/cross.png";
                            imgAttemptPassed.AlternateText = "No";
            }
        }
    }
}
}

and

public void myRadGrid_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.ExportToExcelCommandName)
            {
                myRadGrid.ExportSettings.ExportOnlyData = true;
                myRadGrid.ExportSettings.Excel.Format = GridExcelExportFormat.Html;
                myRadGrid.ExportSettings.IgnorePaging = true;
                myRadGrid.ExportSettings.FileName = "SpeakerCertificationReport";
                myRadGrid.ExportSettings.OpenInNewWindow = true;
                myRadGrid.MasterTableView.ExportToExcel();
            }
}

Hope this helps.

Thank you
Ellie
Tags
Grid
Asked by
Leela Prasad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Leela Prasad
Top achievements
Rank 1
Elitsa
Top achievements
Rank 1
Share this question
or