aspnetcore-devexpress-dot-aspnetcore-dot-spreadsheet-dot-spreadsheetbuilder-dot-open-x28-system-dot-string-devexpress-dot-spreadsheet-dot-documentformat-system-dot-func-system-dot-io-dot-stream-x29.md
Opens a document in the specified format from a stream.
Namespace : DevExpress.AspNetCore.Spreadsheet
Assembly : DevExpress.AspNetCore.Spreadsheet.v25.2.dll
NuGet Package : DevExpress.AspNetCore.Spreadsheet
public SpreadsheetBuilder Open(
string documentId,
DocumentFormat documentFormat,
Func<Stream> contentAccessorByStream
)
| Name | Type | Description |
|---|---|---|
| documentId | String |
| | documentFormat | DocumentFormat |
A document format.
| | contentAccessorByStream | Func<Stream> |
A method delegate that obtains a stream.
|
| Type | Description |
|---|---|
| SpreadsheetBuilder |
An object that can be used to further configure the Spreadsheet.
|
This method overload allows you to disable automatic format detection and improve performance when the Spreadsheet opens a document. Call the Open(String, Func<Stream>) method to determine the document’s format automatically when you open a document. Refer to the following section for more information: Open a Document from a Stream.
The example below demonstrates how to open a document from a stream:
@model SpreadsheetDocumentContent
@(Html.DevExpress()
.Spreadsheet("spreadsheet")
.Open(@Model.DocumentId, DocumentFormat.Xlsx, @Model.ContentAccessorByStream)
)
public IActionResult Index() {
Func<Stream> contentAccessorByStream = () => System.IO.File.Open("your-file-path", FileMode.Open);
var model = new SpreadsheetDocumentContent(DocumentId1, contentAccessorByStream);
return View(model);
}
public class SpreadsheetDocumentContent {
public string DocumentId { get; set; }
public Func<Stream> ContentAccessorByStream { get; set; }
public DocumentFormat DocumentFormat { get; set; } = DocumentFormat.Xlsx;
public SpreadsheetDocumentContent(string documentId, Stream contentAccessorByStream) {
DocumentId = documentId;
ContentAccessorByStream = contentAccessorByStream;
}
}
See Also