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

Excel Export Problem

25 Answers 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Nov 2009, 02:13 PM
I am having a problem exporting from my grid to Excel.  When issuing the export it creates the file for export and I can save the excel file to disc and open from disc fine. However when I try to open the document directly from the server response I get an error as shown in the file attached to this forum post.

I am not sure whats going on because this used to work fine.  And it's happening across the application, not specific to 1 grid.  I know that there have been 2 updates to the telerik controls since these were implemented...  the most recent version prior to Q3.  and Q3.

I have a link button on the commanditem bar and use the ItemCommand event for the export as:

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
COMMAND_NAME = e.CommandName

Select Case COMMAND_NAME

    Case "RemoveFilters"
 bResetSelections = True
    Case RadGrid.ExportToExcelCommandName
 Dim t As DateTime = Now()
 bExport = True
 Dim sHTML As String = ""
 sHTML += "<div align='left' style='font-weight:bold;color:Blue;font-size:large'>Regulation Tracking System</div>"
 sHTML += "<div align='left' style='font-weight:bold;color:Blue'>Regulation Records Data Dump</div>"
 sHTML += "<div align='left' style='font-weight:bold;color:Blue'>" + t.ToLongDateString() + "</div>"
 sHTML += "<div>&nbsp;</div>"
 RadGrid1.MasterTableView.Caption = sHTML
 RadGrid1.ExportSettings.FileName = RTS.GetFileName("RegulationRecords")
 RadGrid1.ExportSettings.IgnorePaging = True
 RadGrid1.ExportSettings.ExportOnlyData = True
 RadGrid1.ExportSettings.OpenInNewWindow = True
 RadGrid1.MasterTableView.ExportToExcel()

End Select

End Sub




25 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 23 Nov 2009, 09:01 AM
Hello Robert,

Please try to reproduce this using our online example and let us know about the result.

All the best,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Robert
Top achievements
Rank 1
answered on 23 Nov 2009, 05:49 PM
Seems the issue was due to the length of the filename I am assigning:

I reduced the length of the name and it's working as it should.

http://support.microsoft.com/kb/326039

0
Mark Galbreath
Top achievements
Rank 2
answered on 23 Nov 2009, 10:24 PM
Must have been some file name!  You are allowed 256 chars.
0
Robert
Top achievements
Rank 1
answered on 23 Nov 2009, 10:37 PM
Well.. that brings up another issue. For some reason the filename appears encoded hence the extremely long name.
0
Pavlina
Telerik team
answered on 24 Nov 2009, 10:20 AM
Hi Robert,

As we promised in the support ticket we will remove the explicit encoding for IE6 and IE7.
The fix will be included in the next release of RadControls for ASP.NET AJAX. The expected release date is around the midst of December.

Please excuse us for the inconvenience.

Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 24 Nov 2009, 01:47 PM
Robert,
I was getting those URL-encoded filenames too, until I switched from export's default (HTML) to ExcelML.

Nevertheless, I have not been able to get export to work with command link buttons and notice you are testing for a args value of 

RadGrid.ExportToExcelCommandName

Is this right?  I have been testing for simply "ExportToExcelCommand" and got nowhere.  Of course (and you knew this was coming), the documentation should cover this, if there was any documentation.

Cheers!
Mark
0
Robert
Top achievements
Rank 1
answered on 24 Nov 2009, 03:06 PM
The part that doesnt make sense to me is that it only happens on my grids.  What makes this different that the grid in your demo?  There is nothing special about the data or the grid I am using.

Hey Mark... I believe RadGrid.ExportToExcelCommandName is in the documentation.  Then again it may have been used in one of their demos.  Whats aggravating is that this used to work just fine. 
0
Robert
Top achievements
Rank 1
answered on 24 Nov 2009, 03:07 PM
Then again... we may have been testing this in IE 6.0 when it was workig fine now that I think about it.
0
Robert
Top achievements
Rank 1
answered on 24 Nov 2009, 05:50 PM
Mark,

Why havent you been able to get the exporting to work with command item links?

Are you getting scripting error?  If so you probably need to turn off Ajax on the export. 

Here's what I do:

 

function mngRequestStarted(ajaxManager, eventArgs)

 

{

// disable ajax on the grid for the excel export.

 

 

if (eventArgs.get_eventTarget().indexOf("lnkExcel") != -1) {

 

eventArgs.set_enableAjax(

false);

 

}

 

}

 


Robert
0
Daniel
Telerik team
answered on 26 Nov 2009, 06:04 PM
Hello Robert,

A fixed version will be available in the latest internal builds in the next week.

Excuse us for the inconvenience.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Nicolaï
Top achievements
Rank 2
answered on 01 Dec 2009, 10:13 AM
Hi,

Had problems with exports.
Started digging for an ajax ie6 issue, but it turned out to be the inch symbol (") in filenames in office 2000.
(It was working fine on my ie7, firefox / Office 2003 setup, but not on the old user machines)
This thread reminded me about file name issues, thanks.
Just adding a note for others: watch out for those ugly symbols in file name...

Best regards,
Nicolai
0
Daniel
Telerik team
answered on 01 Dec 2009, 11:28 AM
Hello Nicolai,

Thank you for the clarification.

I'd like to note that versions prior to Microsoft Office 2003 are not supported.
As to the quotes - depending on the browser you will observe different behavior. Internet Explorer 8 will probably replace the quote with an underscore. I believe Firefox 3.5 will replace the whole name with the default one.
<ExportSettings FileName="a\"" ... />

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 01 Dec 2009, 11:38 AM
Daniel wrote:
A fixed version will be available in the latest internal builds in the next week.  
Excuse us for the inconvenience.  
 

Daniel, I've been looking for a new build.  What is the diff between a "dev" and a "trial" hotfix?

Cheers!
Mark
0
Nicolaï
Top achievements
Rank 2
answered on 01 Dec 2009, 12:22 PM
Hi,

"I'd like to note that versions prior to Microsoft Office 2003 are not supported."

- I'm aware of that, but my users are all on office 2000 and ie6.
So what can we do... I'm sure others (Telerik users) have a similar situation...
MUST have excel export; MUST make it work, supported or not....
So far, I've usually gotten the export to work; limitations can usually be overcome one way or another...
File names is one limitation that can be very easily overcome.

Best regards,
Nicolai
0
Robert
Top achievements
Rank 1
answered on 01 Dec 2009, 02:27 PM
I agree, this is such a stupid problem to have.  Microsoft's limitation and Microsoft's handywork once again shooting themselves in the foot.
0
Daniel
Telerik team
answered on 01 Dec 2009, 09:59 PM
Hello guys,

@Mark: The so-called "dev" build is intended for our licensed customers. And the contrariwise, the "trial" build is for the trial users.
We are not ready with the depicted hotfix yet, but it will be released in the next few days as I promised.

@Nicolai: I believe I understand the situation very well and I'm glad that you found a way to overcome the limitation. Keep up the good work.

@Robert: We are constrantly trying to avoid the limitations but in some cases it is not in our power to sidestep the unwanted behavior.

Regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
GP
Top achievements
Rank 1
answered on 02 Dec 2009, 03:53 PM
Hi, Daniel and the Telrik team.  I am having trouble with exporting too.  I am using a 2009 Q3 radgrid with an ajax manager.  I am using the new export features in the commanditemsettings:

            <CommandItemSettings 
                    ShowExportToWordButton="true" 
                    ShowExportToExcelButton="true"  
                    ShowExportToCsvButton="true" 
                    ShowExportToPdfButton="true" 
                    />

This worked until I put in the ajax manager.  Now it's broken.  The buttons look like they are there, and the alt tags pop up.  However, when I click on any of the buttons, nothing happens.  I tried using the information provided at this link: http://www.telerik.com/community/code-library/aspnet-ajax/general/export-radgrid-content-to-excel-word-csv-pdf-with-ajax-enabled.aspx,  but it's not working.  Am I naming the buttons wrong?  Is there more code that I am missing?

Here's the two snippets of code I tried:
ASP attempt:
 
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        <script type="text/javascript">  
            function mngRequestStarted(ajaxManager, eventArgs)  
            { 
                if (eventArgs.get_eventTarget().indexOf("ExportToExcelButton") != -1)  
                    eventArgs.set_enableAjax(false);  
            }  
        </script>  
    </telerik:RadCodeBlock> 
<%--further down the line I have this code:--%> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" ClientEvents-OnRequestStart="mngRequestStarted"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="Button1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1"  
                        LoadingPanelID="RadAjaxLoadingPanel1" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
                <telerik:AjaxSetting AjaxControlID="ExportToExcelButton"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> 
                        <telerik:AjaxUpdatedControl ControlID="ExportToExcelButton" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
        </AjaxSettings> 
        <ClientEvents OnRequestStart="mngRequestStarted" /> 

VB attempt - This happens after I bind the data to the grid:
        Dim cmdItem As GridCommandItem 
        cmdItem = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem)(0) 
 
        Dim btncmd As New Button 
        btncmd = cmdItem.FindControl("ExportToExcelButton"
        RadScriptManager1.RegisterPostBackControl(btncmd) 
 
        btncmd = cmdItem.FindControl("ExportToWordButton"
        RadScriptManager1.RegisterPostBackControl(btncmd) 
 
        btncmd = cmdItem.FindControl("ExportToCSVButton"
        RadScriptManager1.RegisterPostBackControl(btncmd) 
 
        btncmd = cmdItem.FindControl("ExportToPDFButton"
        RadScriptManager1.RegisterPostBackControl(btncmd) 
 
 

Thank you for your help in this matter.  I hope you have a terrific day.


0
Robert
Top achievements
Rank 1
answered on 02 Dec 2009, 04:05 PM

I am not sure about the "New" method of exorting you are referring to but... You need to give your command item links the CommandName property either in the designer or as so:

<asp:LinkButton Font-Underline="true" CssClass="clink" ID="lnkExcel" runat="server" CommandName="ExportToExcel" ToolTip="Export Analyst / Author List To Excel">XLS</asp:LinkButton>

Then you need to handle the RadGrid1_ItemCommand() event and initiate the export:

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
    COMMAND_NAME = e.CommandName

    Select Case COMMAND_NAME

    Case RadGrid.ExportToExcelCommandName
         RadGrid1.MasterTableView.Caption = sHTML
         RadGrid1.ExportSettings.FileName = RTS.GetFileName("RegulationRecords")
         RadGrid1.ExportSettings.IgnorePaging = True
         RadGrid1.ExportSettings.ExportOnlyData = True
         RadGrid1.ExportSettings.OpenInNewWindow = True
         RadGrid1.MasterTableView.ExportToExcel()

    End Select

End Sub

 

 

 

 

 




 

 

0
GP
Top achievements
Rank 1
answered on 02 Dec 2009, 05:52 PM
Actually, it's a demo project in the Q3 "What's New" section: http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx.  Oddly enough, that demo also has the fix for the "new" method on it in the .aspx code example.  Whew!

If I had looked a little bit more closely at that demo sooner, I would have figured it out much more quickly.

Thanks for the help!
0
Accepted
Daniel
Telerik team
answered on 10 Dec 2009, 07:38 PM
Hello,

I wanted to let you know that we solved the problem with the encoded file names. You can test the latest release of RadControls Q3 2009 SP1.

As usual, your feedback is welcome.
 
Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 10 Dec 2009, 10:50 PM
Thanks, Daniel, but that link goes no where useful, and I can't find 2009_Q3 beta or 2009_03_1208 anywhere.  Where is it?

Cheers!
Mark
0
Robert
Top achievements
Rank 1
answered on 10 Dec 2009, 10:53 PM
You need to login, go to your account and then click on downloads.  The updated SP will be at the top.
0
Mark Galbreath
Top achievements
Rank 2
answered on 14 Dec 2009, 12:35 PM
Actually, it's not.  Q3 2009 beta is there (now), but no Q3 2009 SP1.

Mark
0
Daniel
Telerik team
answered on 14 Dec 2009, 02:35 PM
Hello Mark,

I believe your license doesn't allow you download the latest version. Please examine the following links:
License Comparison
Telerik Premium Collection for .NET

Don't hesitate to contact us if you need more information.
Contact Sales

Best regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Mark Galbreath
Top achievements
Rank 2
answered on 14 Dec 2009, 02:52 PM
Hell, I couldn't afford the license I did buy!  Tightwad company wouldn't underwrite it.

Cheers!
Mark
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Robert
Top achievements
Rank 1
Mark Galbreath
Top achievements
Rank 2
Daniel
Telerik team
Nicolaï
Top achievements
Rank 2
GP
Top achievements
Rank 1
Share this question
or