You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ej2-asp-core-mvc/spreadsheet/open-save.md
+104-1Lines changed: 104 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -276,6 +276,52 @@ Please find the code to fetch the blob data and load it into the Spreadsheet con
276
276
{% endtabs %}
277
277
{% endif %}
278
278
279
+
### To open an Excel file located on a server
280
+
281
+
By default, the Spreadsheet control provides an option to browse files from the local file system and open them within the control. If you want to load an Excel file located on a server, you need to configure the server endpoint to fetch the Excel file from the server location, process it using `Syncfusion.EJ2.Spreadsheet.AspNet.Core`, and send it back to the client side as `JSON data`. On the client side, you should use the `openFromJson` method to load that `JSON data` into the Spreadsheet control.
// Processing the Excel file and return the workbook JSON.
294
+
varresult=Workbook.Open(open);
295
+
fileStream.Close();
296
+
returnContent(result);
297
+
}
298
+
299
+
publicclassFileOptions
300
+
{
301
+
publicstringFileName { get; set; } =string.Empty;
302
+
}
303
+
```
304
+
305
+
```js
306
+
307
+
// Fetch call to server to load the Excel file.
308
+
fetch('Home/Open', {
309
+
method:'POST',
310
+
headers: {
311
+
'Content-Type':'application/json',
312
+
},
313
+
body:JSON.stringify({ FileName:'Sample' }),
314
+
})
315
+
.then((response) =>response.json())
316
+
.then((data) => {
317
+
// Load the JSON data into spreadsheet.
318
+
spreadsheet.openFromJson({ file: data });
319
+
})
320
+
321
+
```
322
+
323
+
You can find the server endpoint code to fetch and process the Excel file in this [attachment](https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1_(1)-880363187).
324
+
279
325
### External workbook confirmation dialog
280
326
281
327
When you open an excel file that contains external workbook references, you will see a confirmation dialog. This dialog allows you to either continue with the file opening or cancel the operation. This confirmation dialog will appear only if you set the `AllowExternalWorkbook` property value to **false** during the open request, as shown below. This prevents the spreadsheet from displaying inconsistent data.
@@ -550,6 +596,64 @@ Please find below the code to retrieve blob data from the Spreadsheet control be
550
596
{% endtabs %}
551
597
{% endif %}
552
598
599
+
### To save an Excel file to a server location
600
+
601
+
By default, the Spreadsheet control saves the Excel file and downloads it to the local file system. If you want to save an Excel file to a server location, you need to configure the server endpoint to convert the spreadsheet data into a file stream and save it to the server location. To do this, first, on the client side, you must convert the spreadsheet data into `JSON` format using the `saveAsJson` method and send it to the server endpoint. On the server endpoint, you should convert the received spreadsheet `JSON` data into a file stream using `Syncfusion.EJ2.Spreadsheet.AspNet.Core`, then convert the stream into an Excel file, and finally save it to the server location.
602
+
603
+
```js
604
+
605
+
// Convert the spreadsheet workbook to JSON data.
606
+
spreadsheet.saveAsJson().then((json) => {
607
+
constformData=newFormData();
608
+
formData.append('FileName', "Sample");
609
+
formData.append('saveType', 'Xlsx');
610
+
// Passing the JSON data to perform the save operation.
You can find the server endpoint code to save the spreadsheet data as an Excel file in this [attachment](https://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication1_(1)-880363187).
656
+
553
657
### Supported file formats
554
658
555
659
The following list of Excel file formats are supported in Spreadsheet:
@@ -587,7 +691,6 @@ To save the Spreadsheet document as an `xlsx, xls, csv, or pdf` file, by using `
587
691
{% endif %}
588
692
589
693
590
-
591
694
## Server Configuration
592
695
593
696
In Spreadsheet component, import and export operation processed in `server-side`, to use importing and exporting in your projects, it is required to create a server with any of the following web services.
0 commit comments