OLE Objects

This demo uses the DevExpress Word Processing Document API to generate a new Word document and add an OLE object linked to an Excel worksheet.

Click Generate OLE Object and Save as… to select an output format, generate a document, and download the result.

OLE Object
InvestmentPortfolio.xlsx



using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;

async Task<Stream> GenerateDocumentWithOleObject(Stream oleObjectStream, string objectType, Stream imageStream, DocumentFormat targetFormat) {
    using var wordProcessor = new RichEditDocumentServer();
    var document = wordProcessor.Document;

    var oleShape = document.Shapes.InsertOleObjectAsIcon(document.Range.Start, oleObjectStream, objectType, DocumentImageSource.FromStream(imageStream));
    oleShape.TextWrapping = TextWrappingType.InLineWithText;

    var outputStream = new MemoryStream();
    wordProcessor.SaveDocument(outputStream, targetFormat);
    outputStream.Position = 0;
    return outputStream;
}