OLE resize issue when multiple pages

Hi team,

When we are having multiple pages in excel, the OLE size has changed. But when we have single page ole, it’s working fine. I have raised the same issue in the Slides forum. But they have asked me to raise in the Cells forum. For more details, could you please visit the below link.

<a href="https://forum.aspose.com/t/11505

I have attached all the documents in the above link. Could you please do the needful.

Regards
Prabu R

Hi Prabu,


Thank you for contacting Aspose support.

I have evaluated your presented scenario (OLE size in presentation file) and I am not able to observe any problem with the resultant images (EMF) or the presentation file. Please note, I have used the latest revisions of the both APIs (Aspose.Cells for Java 8.7.1.3 & Aspose.Slides for Java 16.1.0.0). Please find the attachment for an archive containing the images generated by SheetRender and the final presentation file.

As far as working of Aspose.Cells APIs is concerned, it is only converting the worksheet contents to images as per specified page breaks. If you check your provided spreadsheet Multiple_page_excel.xlsx in Excel’s Print Preview and compare it with the EMF images attached here, you will find that contents in the images match with Excel’s Print Preview so I believe Aspose.Cells for Java API is working fine for its part.

Please feel free to write back in case you have any concerns.

Java

Workbook workbook = new Workbook(dir + “Multiple_page_excel.xlsx”);
// Create slide
Presentation presentation = new Presentation();
ISlide slide = presentation.getSlides().get_Item(0);
// Get chart worksheet
Worksheet sheet = workbook.getWorksheets().get(“Chart”);
workbook.getWorksheets().setActiveSheetIndex(0);
sheet.getPageSetup().setLeftMargin(0.0);
sheet.getPageSetup().setRightMargin(0.0);
sheet.getPageSetup().setTopMargin(0.0);
sheet.getPageSetup().setBottomMargin(0.0);

// Get the chart worksheet as image
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions();
imageOptions.setImageFormat(ImageFormat.getEmf());
imageOptions.setPrintingPage(PrintingPageType.DEFAULT);
imageOptions.setOnePagePerSheet(false);
imageOptions.setOnlyArea(false);
SheetRender sheetRender = new SheetRender(sheet, imageOptions);
CellArea[] area = sheet.getPrintingPageBreaks(imageOptions);
// Add the workbook on slide
float oleX = 0f;
float oleY = 0f;
float oleHeight = (float)presentation.getSlideSize().getSize().getHeight();
float oleWidth = (float)presentation.getSlideSize().getSize().getWidth();

byte[] imageByteArray = null;
byte[] workbookByteArray = null;
ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
ByteArrayOutputStream workBookStream = new ByteArrayOutputStream();
System.out.println(“Area length------>”+area.length);
for (int j = 0; j < sheetRender.getPageCount(); j++)
{
sheetRender.toImage(j, dir + sheet.getName() + " Page" + (j+1) + “.emf”);
imageStream.reset();
sheetRender.toImage(j, imageStream);
imageByteArray = imageStream.toByteArray();

int oleStartRow = 0;
int oleStartColumn = 0;
int oleEndRow, oleEndColumn;
int numrows;
int numcols;

System.out.println(“Multipage”);
oleStartRow = area[j].StartRow;
oleStartColumn = area[j].StartColumn;
oleEndRow = area[j].EndRow;
oleEndColumn = area[j].EndColumn;
numrows = area[j].EndRow - oleStartRow + 1;
numcols = area[j].EndColumn - oleStartColumn + 1;
System.out.println("Number of rows and cols in “+j+” Page "+numrows + " " + numcols);
workbook.getWorksheets().setOleSize(oleStartRow, oleEndRow, oleStartColumn, oleEndColumn);
sheet.freezePanes(oleEndRow, oleEndColumn, oleEndRow, oleEndColumn);

// Get workbook as OLE object data
workBookStream.reset();
workbook.save(workBookStream, com.aspose.cells.SaveFormat.XLSX);
workbookByteArray = workBookStream.toByteArray();

IOleObjectFrame frame = slide.getShapes().addOleObjectFrame(oleX, oleY, oleWidth, oleHeight, “Excel.Sheet.12”, workbookByteArray);
frame.getSubstitutePictureFormat().getPicture().setImage(presentation.getImages().addImage(imageByteArray));

// Write the presentation
slide = presentation.getSlides().addEmptySlide(presentation.getLayoutSlides().getByType(SlideLayoutType.Blank));
}
presentation.getSlides().removeAt(sheetRender.getPageCount());
presentation.save(dir + “Multiple_page_ole.pptx”, 3);

Hi Babar Raza,

Thank you for your detailed response. Your explanation is very well.

My issue is not generating the images and put it into slides. My issue is in OLE object. When we double clicked the image, the OLE window has opened. When we closed the OLE window, the slide size has changed. I thought of it might be the problem from Slides side. But they only asked me to raise the query in the Cells forum. Anyway they have accepted the issue and raised the ticket in Slides.

Regards
Prabu R

Hi Prabu,


It is good to know that Aspose.Slides team is able to observe the problem and have logged it for further investigation. Let us wait for the analysis results of the ticket SLIDESJAVA-35290 in order to move forward with the investigation of this scenario.