officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-oleformat-ffa16bc1.md
Returns the embedded OLE object’s raw data.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
byte[] GetRawData()
Function GetRawData As Byte()
| Type | Description |
|---|---|
| Byte[] |
A byte array that contains extracted data. Null ( Nothing in Visual Basic) for a linked OLE object.
|
The following example loads spreadsheet data from a Word document into the Spreadsheet Document API component. You can modify and save this data to a file.
Important
You need a license to the DevExpress Office File API or DevExpress Universal Subscription to use this example in production code. Refer to the following page for pricing information: DevExpress Subscriptions.
using System.Linq;
using DevExpress.XtraRichEdit.API.Native;
// Add references to DevExpress.Docs.dll
// and DevExpress.Spreadsheet.Core.dll.
using DevExpress.Spreadsheet;
// ...
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)
{
// Retrieve data from the OLE object.
byte[] spreadsheetData = embeddedObject.OleFormat.GetRawData();
// Create a Workbook instance.
using (Workbook workbook = new Workbook()) {
// Load data into the workbook.
workbook.LoadDocument(spreadsheetData);
// Modify data.
// ...
// Save the document.
workbook.SaveDocument("ExcelDocument.xlsx", DevExpress.Spreadsheet.DocumentFormat.Xlsx);
}
}
Imports System.Linq
Imports DevExpress.XtraRichEdit.API.Native
' Add references to DevExpress.Docs.dll
' and DevExpress.Spreadsheet.Core.dll.
Imports DevExpress.Spreadsheet
' ...
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
' Retrieve data from the OLE object.
Dim spreadsheetData() As Byte = embeddedObject.OleFormat.GetRawData()
' Create a Workbook instance.
Using workbook As New Workbook()
' Load data into the workbook.
workbook.LoadDocument(spreadsheetData)
' Modify data.
' ...
' Save the document.
workbook.SaveDocument("ExcelDocument.xlsx", DevExpress.Spreadsheet.DocumentFormat.Xlsx)
End Using
End If
See Also