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

What should be ProxyURL() when Kendo Grid exporting to excel?

1 Answer 2263 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 06 May 2019, 08:02 PM

Hi,

In my MVC project, I copied sample code(See below example) in my Index.cshtml file. I did not write server side function Excel_Export_Save() anywhere. Why below setting still worked in my project?
Furthermore, I changed "Excel_Export_Save" to other things, it still worked.

What  is the meaning of  “.ProxyURL(Url.Action("Excel_Export_Save", "Grid"))”  then? Thanks.



.Excel(excel => excel
.FileName("Kendo UI Grid Export.xlsx")
.Filterable(true)
.ProxyURL(Url.Action("Excel_Export_Save", "Grid"))

1 Answer, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 08 May 2019, 11:10 AM
Hi Daochuen,

Unless you set ForceProxy(true) in the export settings, the ProxyUrl setting will not be used in most scenarios. The proxy method is used to save the Excel file through the server in browser that don't support local file saving (IE 10, Safari). If you run your project in such browser with the current configuration, a request will be made to the provided URL, which will result in a 404 error and no file fill be saved.

The usage of the proxyUrl and forceProxy settings is described in detail in the following article about Kendo UI:
Set Server Proxy

The information is fully applicable for UI for ASP.NET MVC as well because it uses kendo.saveAs internally when saving exported files.

Regards,
Tsvetina
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Pavel
Top achievements
Rank 1
commented on 15 Jan 2022, 10:24 PM | edited

Hello, I've got ForceProxy(true) etc. but proxy method is not being called on controller.. ? any ideas?

 

 

Yanislav
Telerik team
commented on 18 Jan 2022, 02:23 PM

A possible reason for such an issue is the size of the request. If are exported multiple records, the count of the records increases the JSON passed back and forth, thus its size may exceed the default limit set by the ASP.NET MVC Framework. To fix it, you can try the suggestion from the documentation we have on this exception:

https://docs.telerik.com/aspnet-mvc/html-helpers/data-management/grid/troubleshoot/known-exceptions#json-javascriptserializer-serialization-or-deserialization-error

Alternatively, try the following approach and set the maxJsonLength to a greater than the default value:

 

<configuration> 
   <system.web.extensions>
       <scripting>
           <webServices>
               <jsonSerialization maxJsonLength="50000000"/>
           </webServices>
       </scripting>
   </system.web.extensions>
</configuration> 

 

You can read more about this topic in the following article :

https://stackoverflow.com/questions/5692836/maxjsonlength-exception-in-asp-net-mvc-during-javascriptserializer

Another possible reason, If no export happens at all on your side, then there is probably some JavaScript error that prevents the export. Can you confirm that you included the jszip library in your project? It is required for Excel export:

<script src="//cdnjs.cloudflare.com/ajax/libs/jszip/2.4.0/jszip.min.js"></script>

If the library is included, please open the browser developer tools (F12) Console tab and check for any JS errors during export.Other than that, everything with the posted configuration seems fine and there should be no such problems.

I hope this clarifies the behavior and the above information will help you resolve the issue.

Tags
Grid
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Tsvetina
Telerik team
Share this question
or