Hi team.
When I download the Excel file I get error 405
Below is the CURL:
Hi Ngoc Hoang,
We have reviewed the details you shared. To replicate the reported problem, we
first attempted to load the JSON data from your shared save.json file into the
spreadsheet using the openFromJson() method. We then
planned to save the spreadsheet with the loaded JSON data as an Excel file.
However, in the shared JSON file, some formulas included double quotes within
double quotes, such as "=+IFERROR(S9/R9-1, \\"-\\")". This caused an issue when loading the JSON data into the spreadsheet.
After correcting these instances to use single quotes within the double quotes,
like "=+IFERROR(S9/R9-1, \\'-\\')", the JSON data was
successfully loaded into the spreadsheet using the openFromJson() method.
Once the data was loaded, we tried to save the
spreadsheet as an Excel file by choosing the option 'File > Save As'
in the file menu. However, a 405
error occurred on our end also when using the hosted Syncfusion service URLs.
To resolve this issue, we suggest using the local service. However, when using
the local service with your JSON data, the error 'Failed to read the request
form. Form key length limit 2048 or value length limit 4194304 exceeded'
occurs. This happens due to an HTTP request limit when handling large amounts
of data, as the server restricts the size of HTTP requests. This issue can also
be resolved by updating the server settings to allow larger HTTP requests in
your local service.
Therefore, we suggest the following steps to resolve this issue:
Use the local service:
Firstly, we would like to let you know that in our Online Demo samples, we use hosted Syncfusion service URLs for the Open and Save actions, and these hosted URLs are only intended for demo purposes. Therefore, we always recommend avoiding the use of these online services for development purposes. Instead, we suggest creating and using your own local service for development purposes.
We kindly inform you that we have implemented the Open and Save
(server-side) functionality in ASP.NET Core and ASP.NET MVC using
the Syncfusion XLSIO library. We use the Syncfusion XLSIO library
on our server to handle these actions. When you open or save a file, the XLSIO
library reads the file and converts it to a format our spreadsheet supports.
For your reference, we have attached a local Web API
service along with a prepared client sample below, where we load your JSON.
Service sample (Web API): Please see the attachment.
Client sample: Zsxdcnx5 (forked) - StackBlitz
After taking the local service from the attachment, please follow the
below steps to launch the local service on your end.
For your convenience, we have attached the open and save code snippets of local service below.
Code snippet (Server side):
|
[HttpPost] [Route("Open")] public IActionResult Open([FromForm]IFormCollection openRequest) { OpenRequest open = new OpenRequest(); open.File = openRequest.Files[0]; return Content(Workbook.Open(open)); }
//Save method [HttpPost] [Route("Save")] public IActionResult Save([FromForm]SaveSettings saveSettings) { return Workbook.Save(saveSettings); }
|
After, launching the local service, you need to update the open and
save URL in the Client-Side sample like in the below code
snippet,
|
saveUrl= 'https://localhost:{port number}/api/spreadsheet/save'
openUrl= 'https://localhost:44354/api/spreadsheet/open' saveUrl= 'https://localhost:44354/api/spreadsheet/save'
|
Note: Launch
the service before running the client-side sample.
For local service you need ASP.NET Core project as a backend for Open/Save
functionality in your client application.
Local service available in below GitHub location also:
https://github.com/SyncfusionExamples/EJ2-Spreadsheet-WebServices/
Create ASP.NET Core project and generate the license based on the below KB
link.
https://www.syncfusion.com/kb/8976/how-to-generate-license-key-for-essential-studio-products
And include the licensed key in your project startup file as like in the below
documentation link.
https://help.syncfusion.com/common/essential-studio/licensing/license-key
Please refer to the documentation below to know more about the open and save
functions in our spreadsheet.
https://ej2.syncfusion.com/react/documentation/spreadsheet/open-save
Alternatively, you can also host and run
our Spreadsheet-oriented service as a Docker image. Utilizing a
Docker image necessitates only a simple and basic Docker environment with
minimal commands to effortlessly host and run our service.
You can utilize the below service and use it for Spreadsheet Open and Save
services, by pulling the spreadsheet docker image and
following the steps from the URL mentioned below.
Spreadsheet docker image: https://hub.docker.com/r/syncfusion/spreadsheet-server
For more information regarding the docker deployment, please refer the below
documentation,
https://ej2.syncfusion.com/react/documentation/spreadsheet/docker-deployment
Update the server settings in
your local service to allow larger HTTP request sizes:
In your local service, we suggest updating the
server settings to allow larger HTTP requests. By adding the following code
to the ConfigureServices method in your Startup.cs file, the
server will be able to handle larger requests without encountering the issue
you're facing. Please use the code shared below in your server project to
resolve the reported problem.
[Startup.cs]
|
{ services.Configure<FormOptions>(x => { x.MultipartBodyLengthLimit = int.MaxValue; x.ValueLengthLimit = int.MaxValue;
}); …………… } |
Kindly
review the details shared above. If you still face the same issue while using
the local service, please share how you tried to save the spreadsheet as an
Excel file on your end. Additionally, please provide details on how you
obtained the JSON data you shared. Based on the information you provide, we
will review and offer a quicker, more effective solution.
Thank you for your excellent response!
Hi Ngoc Hoang,
We hope your issue has been resolved. Please feel free to reach out to us if
you need any further assistance.