Can not save spreadsheet

Hi team. 

When I download the Excel file I get error 405

"@syncfusion/ej2-react-spreadsheet": "28.1.33",


Below is the CURL:


Image_6137_1736153415937


Attachment: save_e301c675.zip

3 Replies

JS Janakiraman Sakthivel Syncfusion Team January 8, 2025 05:20 PM UTC

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:


  1. Use the local service instead of the hosted Syncfusion service.
  2. Update the server settings in your local service to allow larger HTTP request sizes


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.

  1. Download and unzip the attached local service (WebAPI).
  2. Open the WebAPI.sln file in the WebAPI folder.
  3. In that right click on the Dependencies folder inside WebAPI.
  4. Then, click the Manage Nuget Packages.
  5. In Browse, search Syncfusion.EJ2.Spreadsheet.AspNet.Core package and install the latest package.
  6. If already, the package exists, remove the package, and re-install it to get the latest package with its necessary dependent packages will get downloaded.
  7. Now, build the solution and run in a local host.


For your convenience, we have attached the open and save code snippets of local service below.

Code snippet (Server side):


//Open method

[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,


openUrl= 'https://localhost:{port number}/api/spreadsheet/open'

saveUrl= 'https://localhost:{port number}/api/spreadsheet/save'


Example:

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]


public void ConfigureServices(IServiceCollection services)

{

    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.


Attachment: WebAPI_b786193f.zip


NH Ngoc Hoang replied to Janakiraman Sakthivel January 16, 2025 03:52 AM UTC

Thank you for your excellent response!



JS Janakiraman Sakthivel Syncfusion Team January 17, 2025 09:57 AM UTC

Hi Ngoc Hoang,

We hope your issue has been resolved. Please feel free to reach out to us if you need any further assistance.


Loader.
Up arrow icon