Skip to main content
All docs
V22.2
.NET Framework 4.5.2+

OleFormat.SaveAs(Stream) Method

Saves data of the embedded OLE object to a stream.

Namespace: DevExpress.XtraRichEdit.API.Native

Assembly: DevExpress.RichEdit.v22.2.Core.dll

NuGet Package: DevExpress.RichEdit.Core

Declaration

void SaveAs(
    Stream stream
)

Parameters

Name Type Description
stream Stream

The output stream.

Exceptions

Type Description
InvalidOperationException

Occurs when you call the SaveAs method for a linked OLE object.

Remarks

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);
    }
}
See Also