Excel Export Problem

26 posts, 1 answers
  1. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 21 Nov 2009 Link to this post

    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




  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 23 Nov 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 23 Nov 2009 Link to this post

    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

  5. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 23 Nov 2009 Link to this post

    Must have been some file name!  You are allowed 256 chars.
  6. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 23 Nov 2009 Link to this post

    Well.. that brings up another issue. For some reason the filename appears encoded hence the extremely long name.
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 24 Nov 2009 Link to this post

    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.
  8. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 24 Nov 2009 Link to this post

    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
  9. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 24 Nov 2009 Link to this post

    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. 
  10. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 24 Nov 2009 Link to this post

    Then again... we may have been testing this in IE 6.0 when it was workig fine now that I think about it.
  11. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 24 Nov 2009 Link to this post

    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
  12. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 26 Nov 2009 Link to this post

    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.
  13. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 01 Dec 2009 Link to this post

    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
  14. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 01 Dec 2009 Link to this post

    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.
  15. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 01 Dec 2009 Link to this post

    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
  16. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 01 Dec 2009 Link to this post

    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
  17. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 01 Dec 2009 Link to this post

    I agree, this is such a stupid problem to have.  Microsoft's limitation and Microsoft's handywork once again shooting themselves in the foot.
  18. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 01 Dec 2009 Link to this post

    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.
  19. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 02 Dec 2009 Link to this post

    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.


  20. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 02 Dec 2009 Link to this post

    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

     

     

     

     

     




     

     

  21. GP
    GP avatar
    58 posts
    Member since:
    Oct 2009

    Posted 02 Dec 2009 Link to this post

    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!
  22. Answer
    Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 10 Dec 2009 Link to this post

    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.
  23. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 10 Dec 2009 Link to this post

    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
  24. Robert
    Robert avatar
    198 posts
    Member since:
    Aug 2009

    Posted 10 Dec 2009 Link to this post

    You need to login, go to your account and then click on downloads.  The updated SP will be at the top.
  25. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 14 Dec 2009 Link to this post

    Actually, it's not.  Q3 2009 beta is there (now), but no Q3 2009 SP1.

    Mark
  26. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 14 Dec 2009 Link to this post

    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.
  27. Mark Galbreath
    Mark Galbreath avatar
    171 posts
    Member since:
    Jul 2009

    Posted 14 Dec 2009 Link to this post

    Hell, I couldn't afford the license I did buy!  Tightwad company wouldn't underwrite it.

    Cheers!
    Mark
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017