ASPxSpreadsheet.Open(String, Func<Stream>) Method
Opens a document from a stream.
Namespace: DevExpress.Web.ASPxSpreadsheet
Assembly: DevExpress.Web.ASPxSpreadsheet.v24.1.dll
NuGet Package: DevExpress.Web.Office
Declaration
Parameters
Name | Type | Description |
---|---|---|
documentId | String | The document identifier. This value is assigned to the DocumentId property. |
contentAccessorByStream | Func<Stream> | A method delegate to obtain a stream from which to open the document. |
Remarks
Call this Open method to load a document from a stream. Specify the documentId parameter to identify the document. If the specified value is not unique within all open documents, the method activates the previously loaded document with the same documentId and ignores the stream data.
private void CustomDocumentOpening() {
var uniqueDocumentId = GetUniqueDocumentId();
// Open a document from a stream
using (var stream = GetStreamFromCustomDocumentStorage()) {
ASPxSpreadsheet1.Open(uniqueDocumentId, () => stream);
}
}
private string GetUniqueDocumentId() {
throw new NotImplementedException();
// Obtain a previously saved DocumentId (for instance, from a database, if you have previously saved it there):
// return GetDocumentIdFromDatabase();
// or
// Create a new unique identifier:
// return Guid.NewGuid().ToString();
}
private FileStream GetStreamFromCustomDocumentStorage() {
throw new NotImplementedException();
// Provide your custom logic to obtain a document (for instance, from a database)
}
This overload of the Open method determines a document’s format automatically, however this process reduces the method’s performance. Use the Open(String, DocumentFormat, Func<Stream>) overload to improve the method performance.
Note
We recommend that you do not use the LoadDocument method to open a document. When you call this method, the ASPxSpreadsheet does not receive information about the opened document and cannot work with it correctly.