We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Manipulate embedded spreadsheets in a word document (docx\docm)

Hi syncfusion team,

i´m unsure if this message is right here (or for Aspose.cells).
I use Microsoft Open XML SDK and Aspose.Cells to manipulate Word documents, more precisely, manipulate embedded charts and spreadsheets.

For embedded spreadsheets i do following in my current application:

  1. Get all embedded spreadsheets (the underlaying excel document) (for this i use OpenXML)
  2. Add\manipulate data to\on this this excel-documents. (for this i use Aspose.cells)
  3. Save the manipulated sheets back to the word\xml structure. (for this i use OpenXML).
    Next is the point where i have problem:
  4. If you open a docx or docm with a embedded spreadsheet you see only a image\screenshot of the spreadsheet on the word document. This image must be replaced too with an actual image of the manipulated data of the underlaying excel-sheet. Here´s my problem with openXML and Aspose.Cells. Because the docx palceholder has a fixed size, i need a screenshot\image of the worksheet with the same size. But if i use the (only possibility ??) “Aspose.Cells.Rendering.SheetRender” i find no way to set a image size before i call the ToImage() function. So i get a image of all of the data in the worksheet. Because of this, the size of the image could vary. if i place this image to the docx structure and open this file in word the image is stretched or compressed because of the different size settings. Alter the image size in the docx-xml structure to the size of the new image is no possibility.

Is there a possibility in Aspose.Words to save a manipulated Worksheet back to the Word-Structure an automatically replace the corresponding image with an actual one?.

I use. Aspose.Words. 14.8 and Aspose.Cells 8.2.1


Hi Christoph,
Aspose.Words will not automatically replace it but you can remove that OleObject and use the following code to insert new Worksheet on the same place.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Stream memoryStream = File.OpenRead(MyDir + "Book1.xls");
Shape oleObject = builder.InsertOleObject(memoryStream, "Excel.Sheet.8", true, null);
doc.Save(MyDir + @"out.docx");

You can also set Height, Width and other properties exposed by Shape class.
Best Regards,