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,
// 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,