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

Free Support Forum - aspose.com

Avoid Double click for merged object

HI,


We have a word doc template in which we are trying to insert a xls using OLE object. It works properly but there is a small issue. On opening the word doc initially a image is shown where the xls is embeded.
On double click of the image the actual xls sheet is displayed.
Is there any way by which this double click can be avoided, when the word doc is opened the xls sheet should be shown immediately .

Basically further in the program we plan to convert the word into pdf , so the converted pdf also contains the image instead of the xls sheet content.

Thanks

Hi Yatin,

Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does.

Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information about your query along with code.

Hi Tahir,
Thanks for your reply.

I have attached 2 word doc, Present_Format.doc is what is generated by the program while Desired_Format.doc is what is required .

Basically we just want to show the content of the xls sheet in the word doc as read only .So I am not sure whether embedding the xls sheet is the correct approach ? or there is any other way .
After the xls sheet content is displayed in word no further processing in xls is needed.

Thanks

Hi Yatin,

Thanks for your inquiry. In your case, I suggest you please convert the Excel sheet to image using Aspose.Cells and insert that image into Word document using DocumentBuilder.InsertImage method.


Please use following code example to insert worksheet’s image into Word document. Hope this helps you.

Workbook book = new Workbook(MyDir + “in.xlsx”);<o:p></o:p>

//Get the first worksheet.

Worksheet sheet = book.getWorksheets().get(0);

//To remove the white border around the image.

sheet.getPageSetup().setLeftMargin(0);

sheet.getPageSetup().setRightMargin(0);

sheet.getPageSetup().setTopMargin(0);

sheet.getPageSetup().setBottomMargin(0);

//Define ImageOrPrintOptions

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

imgOptions.setImageFormat(ImageFormat.getPng());

//Set only one page would be rendered for the image

imgOptions.setOnePagePerSheet(true);

imgOptions.setPrintingPage(PrintingPageType.IGNORE_BLANK);

//Create the SheetRender object based on the sheet with its

//ImageOrPrintOptions attributes

SheetRender render = new SheetRender(sheet, imgOptions);

render.toImage(0, MyDir + "Out.png");

//Aspose.Words code to insert image in the document.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.insertImage(MyDir + "Out.png");

doc.save(MyDir + "Out.docx");