Your search did not match any results.

Open а 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%") .ShowConfirmOnLosingChanges(false) .DocumentRequestHandlerUrl(Url.Action("DxDocumentRequest")) .Open(documentPath) )
using DevExpress.AspNetCore; using DevExpress.Spreadsheet; using DevExpress.XtraSpreadsheet.Export; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.IO; 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(); } } }