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

Export to Excel Not working after first time in SharePoint

6 Answers 220 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Bharath
Top achievements
Rank 1
Bharath asked on 22 Apr 2011, 05:52 PM
Hello,
I am having a strange issue with Export to Excel option.  It works for the first time and stopes working.  The only way I could make it work is refresh the page and try again.  Also all the other controls on the page stops posting back once I export once.  Following is my scenario. FYI, this does not happen in .NET Web App

Environment: SharePoint Foundation 2010
Type: Visual Webpart

 

 

<telerik:RadGrid ID="ReportRadGrid" runat="server" OnNeedDataSource="ReportsRadGrid_NeedDataSource" Skin="Sunset">

 

 

 

<MasterTableView TableLayout="Auto" CommandItemDisplay="Top" AllowPaging="true" AutoGenerateColumns="false" EnableNoRecordsTemplate="true" ShowHeadersWhenNoRecords="true">

 

 

 

<CommandItemSettings ExportToExcelText="Export to Excel" ShowExportToExcelButton="true" ShowAddNewRecordButton="false" ShowRefreshButton="false" />

 

 

 

<CommandItemTemplate>

 

 

 

<div style="text-align:right">

 

 

 

<telerik:RadButton ID="ExportRadButton" Text="Export to Excel" runat="server" Skin="Sunset" OnClick="ExportRadButton_Click" />

 

 

 

</div>

 

 

 

 

</CommandItemTemplate>

 

 

 

<Columns>

 

 

 

<telerik:GridBoundColumn DataField="Project_x0020_Name" HeaderText="Project Name" />

 

 

 

<telerik:GridBoundColumn DataField="Performing_x0020_Organization" HeaderText="Performing Organization" />

 

 

 

<telerik:GridBoundColumn DataField="Project_x0020_Sponser" HeaderText="Project Sponser" />

 

 

 

<telerik:GridBoundColumn DataField="Status" HeaderText="Status" />

 

 

 

<telerik:GridBoundColumn DataField="Status_x0020_Comments" HeaderText="Status Comments" />

 

 

 

<telerik:GridBoundColumn DataField="Risk_x0020_to_x0020_Project" HeaderText="Risk to Project" />

 

 

 

<telerik:GridBoundColumn DataField="Risk_x0020_Level" HeaderText="Risk Level" />

 

 

 

<telerik:GridBoundColumn DataField="Export_x0020_Date" HeaderText="Publish Date" DataFormatString="{0:MM/dd/yyyy}"/>

 

 

 

</Columns>

 

 

 

</MasterTableView>

 

 

 

<PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" />

 

 

 

<ExportSettings HideStructureColumns="true" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true" />

 

 

 

</telerik:RadGrid>

 



 

 

protected void ExportRadButton_Click(object sender, EventArgs e)

 

 

{

 

 

 

this.ReportRadGrid.MasterTableView.ExportToExcel();

 

 

}

Please let me know if you need more details.

Thanks,
Bharath

6 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 28 Apr 2011, 10:13 AM
Hello Bharath,

Please examine the Export in SharePoint webpart section in the following link:
RadGrid Export Overview

If the problem still persist, please let me know whether your webpart is ajaxified and if it is so, how do you cancel the ajax request?

Regards,
Daniel
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Jay
Top achievements
Rank 1
answered on 28 Apr 2011, 04:18 PM
Hello Daniel,

I am experiencing the same issue in Sharepoint 2007. Thanks for the information you provided. I cant seem to find a solution.

I am using a RadGrid inside a user control that is my web part in the Sharepoint page. I have an export to excel button which exports the grid items to excel using the following code:
RadGridIssues.ExportSettings.IgnorePaging = true;
RadGridIssues.ExportSettings.OpenInNewWindow = true;
RadGridIssues.ExportSettings.ExportOnlyData = true;
RadGridIssues.MasterTableView.ExportToExcel();

Export works fine the first time and after that export doesnt work anymore and none of the controls in that user control work. This includes plain links, sorting in the grid, and drpdown index changed event handler. Without the export functionality everything works fine in the user control.

My webpart is not ajaxified. I tried the solution provided in 'Controls not functional after Export to Excel ...." article in the overview link you provided, but it doesnt solve my problem. Everything works fine if I refrech the page, but i cant expect the end users to do that.
I added the following javascript to my user control as per that article, but no luck:

<script type="text/javascript" language="javascript">

    //sharepoint postback to work after clicking on telerik export to pdf
    if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' && _spBodyOnLoadFunctionNames != null) {
        _spBodyOnLoadFunctionNames.push("supressSubmitWraper");
    }

    function supressSubmitWraper() {
        _spSuppressFormOnSubmitWrapper = true;
    }
</script>

Let me know if I am doing something wrong or if I am missing anything. I am struggling with this.
Thank you.

- Jay

0
Bharath
Top achievements
Rank 1
answered on 28 Apr 2011, 05:12 PM
Suggested Workaround# 3 (below) works for me in Foundation 2010.  Thank you very much.

 

 

//sharepoint postback to work after clicking on telerik export to pdf

 

 

 

if (typeof (_spBodyOnLoadFunctionNames) != 'undefined' && _spBodyOnLoadFunctionNames != null) {

 

 

_spBodyOnLoadFunctionNames.push(

 

"supressSubmitWraper");

 

 

}

 

 

 

function supressSubmitWraper() {

 

 

 

 

_spSuppressFormOnSubmitWrapper = true;

 

 

}

0
Swati
Top achievements
Rank 1
answered on 25 Jul 2013, 08:17 AM
After implementing the workaround #3 as given in post, I am now getting following error.
This happens when the user clicks the excel icon and clicks on "open".
"The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"

Please provide your inputs on the above. Thanks
After clicking "Ok", It opens as empty Excel file.
After cliking "Cancel", it opens the Excel file with exported data.

The result should be just the opposite. On "Ok" it should open the Excel file with exported data.
0
Daniel
Telerik team
answered on 29 Jul 2013, 10:43 AM
Hello Swati,

I'm afraid this is not a known problem so I don't have a ready-to-use solution for you. Could you please try to switch to another Excel format (ExcelML or BIFF) to see whether the issue persists?

Regards,
Daniel
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Swati
Top achievements
Rank 1
answered on 29 Jul 2013, 10:53 AM

The export to Excel is working after I set the following export settings. Thanks

 

 

 

<ExportSettings ExportOnlyData=true OpenInNewWindow=true HideStructureColumns=true >
            <Excel Format="Biff" ></Excel>
        </ExportSettings>
Tags
Grid
Asked by
Bharath
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Jay
Top achievements
Rank 1
Bharath
Top achievements
Rank 1
Swati
Top achievements
Rank 1
Share this question
or