To import an excel file, it needs to be read and converted to client side Spreadsheet model. The converted client side Spreadsheet model is sent as JSON which is used to render Spreadsheet. Similarly, when you save the Spreadsheet, the client Spreadsheet model is sent to the server as JSON for processing and saved. Server configuration is used for this process.
The Spreadsheet component opens an Excel document with its data, style, format, and more. To enable this feature, set allowOpen
as true
and assign service url to the openUrl
property.
In user interface you can open an Excel document by clicking File > Open
menu item in ribbon.
The following code example shows Open
option in the Spreadsheet component.
@Html.EJS().Spreadsheet("spreadsheet").OpenUrl("Open").AllowOpen(true).Render()
public IActionResult Open(IFormCollection openRequest)
{
OpenRequest open = new OpenRequest();
open.File = openRequest.Files[0];
return Content(Workbook.Open(open));
}
The Spreadsheet component saves its data, style, format, and more as Excel file document. To enable this feature, set allowSave
as true
and assign service url to the saveUrl
property.
In user interface, you can save Spreadsheet data as Excel document by clicking File > Save As
menu item in ribbon.
The following code example shows Save
option in the Spreadsheet component.
@Html.EJS().Spreadsheet("spreadsheet").SaveUrl("Save").AllowSave(true).Render()
public void Save(SaveSettings saveSettings)
{
Workbook.Save(saveSettings);
}
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.
- Refer the above open and save operation to shows the create a server using WebAPI configuration for Excel import and export. In ASP.NET Core and ASP.NET MVC you can configure the server in controller.
The following list of Excel file formats are supported in Spreadsheet: