Open embeded word document in excel in new window

Hi Team,

I have code which embeds word document in excel cell.

But while opening the document its opening in the same excel.

Can we open the word document in the new window.

PFB the code.

package com.koduru;

import java.io.File;
import java.io.FileInputStream;

import com.aspose.cells.Cells;
import com.aspose.cells.OleObject;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;
import com.aspose.*;

public class Excell {

/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
//System.setProperty("java.awt.headless", "true");
// This is your image file, you can use any
String imgFile = "D://test.jpg";

// This is your docx file, you can also use Aspose.Words to create docx
// file programmatically

String docFile = "D://testd.docx";

// We need the byte[] byte array for both image and docx file to
// continue

File file = new File(imgFile);

byte[] binaryImg = new byte[(int) file.length()];
FileInputStream fis = new FileInputStream(file);
fis.read(binaryImg);
file = new File(docFile);
byte[] binaryDoc = new byte[(int) file.length()];
fis = new FileInputStream(file);
fis.read(binaryDoc);

// Insert OLE object into a workbook

Workbook workbook = new Workbook();

Worksheet worksheet = workbook.getWorksheets().get(0);

int idxOle = worksheet.getOleObjects().add(1, 1, 50, 50, binaryImg);
OleObject objOle = worksheet.getOleObjects().get(idxOle);
objOle.setObjectData(binaryDoc);
objOle.setProgID("Document");
objOle.setSourceFullName("source.docx");
System.setProperty("java.awt.headless", "true");
worksheet.getCells().setStandardHeight(25f);
Cells cells = worksheet.getCells();
cells.setRowHeight(1, 13);
workbook.save("D://Book1.xlsx");

}

}

Thanks,

Abhinav.

Hi Abhinav,

Thanks for using Aspose.Cells for Java.

Please add the following line. It should then open your word document in a new window.

objOle.setDisplayAsIcon(true);