Your search did not match any results.

Open a Stream

The ASP.NET Core Spreadsheet allows you to open and save documents to an external data storage. This demo demonstrates how to open and save a document as a stream.

  • To open the document, pass a delegate that obtains the target stream as a parameter to the Open method's overload
  • To convert the document to the stream, call the SaveCopy method's overload and specify the document's format as a parameter.
@model SpreadsheetDocumentContentFromStream <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 a Stream", onClick: function (e) { var spreadsheetState = spreadsheet.GetSpreadsheetState(); $.ajax({ type: 'POST', url: '@Url.Action("SaveToStream")', data: { spreadsheetState: spreadsheetState } }); } }); </script> @(Html.DevExpress() .Spreadsheet("spreadsheet") .Height("500px") .Width("100%") .ShowConfirmOnLosingChanges(false) .DocumentRequestHandlerUrl(Url.Action("DxDocumentRequest")) .Open(@Model.DocumentId, DocumentFormat.Xlsx, @Model.ContentAccessorByStream) )
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 FromStream() { string documentName = "Invoice"; string documentId = Path.Combine(DirectoryManagmentUtils.GetDocumentSampleFolderPath(HttpContext), documentName); Func<Stream> contentAccessorByStream = () => DocumentDatabaseMock.GetDocumentContentStream(documentName); var viewmodel = new SpreadsheetDocumentContentFromStream(documentId, contentAccessorByStream); return View(viewmodel); } } }