officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-oleformat-dot-saveas-x28-system-dot-io-dot-stream-x29.md
Saves data of the embedded OLE object to a stream.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
void SaveAs(
Stream stream
)
Sub SaveAs(
stream As Stream
)
| Name | Type | Description |
|---|---|---|
| stream | Stream |
The output stream.
|
| Type | Description |
|---|---|
| InvalidOperationException |
Occurs when you call the SaveAs method for a linked OLE object.
|
The following example shows how to save an embedded OLE object’s data:
using System.Linq;
using DevExpress.XtraRichEdit.API.Native;
// ...
Document document = wordProcessor.Document;
// Obtain an OLE object that stores spreadsheet data.
DevExpress.XtraRichEdit.API.Native.Shape embeddedObject = document.Shapes.FirstOrDefault(
x => x.Type == DevExpress.XtraRichEdit.API.Native.ShapeType.OleObject &&
x.OleFormat.InsertType == OleInsertType.Embedded &&
x.OleFormat.ProgId == OleObjectType.ExcelWorksheet);
if (embeddedObject != null)
{
// Save the OLE object's data as an XLSX document.
using (FileStream stream = new FileStream(@"D:\ExcelDocument.xlsx",
FileMode.Create, FileAccess.ReadWrite))
{
embeddedObject.OleFormat.SaveAs(stream);
}
}
Imports System.Linq
Imports DevExpress.XtraRichEdit.API.Native
' ...
Dim document As Document = wordProcessor.Document
' Obtain an OLE object that stores spreadsheet data.
Dim embeddedObject As DevExpress.XtraRichEdit.API.Native.Shape =
document.Shapes.FirstOrDefault(Function(x) x.Type =
DevExpress.XtraRichEdit.API.Native.ShapeType.OleObject _
AndAlso x.OleFormat.InsertType = OleInsertType.Embedded _
AndAlso x.OleFormat.ProgId = OleObjectType.ExcelWorksheet)
If embeddedObject IsNot Nothing Then
' Save the OLE object's data as an XLSX document.
Using stream As New FileStream("D:\ExcelDocument.xlsx", _
FileMode.Create, FileAccess.ReadWrite)
embeddedObject.OleFormat.SaveAs(stream)
End Using
End If
See Also