Your search did not match any results.

Open a File

This demo illustrates how to use the ASP.NET Core Spreadsheet control to open and save files from the server's file system. To enable these operations, set the path to the file system's root folder as the WorkDirectory) property's value. Use the Open) and SaveCopy) methods with the path parameter to open or save files. To save a document in its original format and location, call the Save method without parameters.

@inject IHostingEnvironment env <div class="button-container"> <div id="button-save"></div> </div> <script type="text/javascript"> $("#button-save").dxButton({ icon: "save", type: "normal", text: "Save copy to file", onClick: function (e) { var spreadsheetState = spreadsheet.getSpreadsheetState(); $.ajax({ type: 'POST', url: '@Url.Action("SaveToFile")', data: { spreadsheetState: spreadsheetState } }); } }); </script> @{ var documentPath = System.IO.Path.Combine( env.ContentRootPath, DirectoryManagmentUtils.GetDocumentSampleFolderPath(Context), "EmployeeInformation.xlsx"); } @(Html.DevExpress() .Spreadsheet("spreadsheet") .Height("500px") .Width("100%") .ConfirmOnLosingChanges(confirm => confirm.Enabled(false)) .DocumentRequestHandlerUrl(Url.Action("DxDocumentRequest")) .Open(documentPath) )
using DevExpress.AspNetCore.Spreadsheet; using DevExpress.Spreadsheet; using DevExpress.XtraSpreadsheet.Export; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using System; using System.IO; using System.Linq; using System.Text; namespace AspNetCoreDemos.Spreadsheet { [Route("[action]")] public class DemosController : Controller { public ActionResult FromFile() { return View(); } [HttpPost] public void SaveToFile(SpreadsheetClientState spreadsheetState) { var spreadsheet = SpreadsheetRequestProcessor.GetSpreadsheetFromState(spreadsheetState); spreadsheet.Save(); } } }