We have generated PPT for reports by the following procedure.
Workbook bookImage = new Workbook(“C:/Suresh/AsposeReports/MBM33_New.xls”);
Worksheet worksheet = bookImage.getWorksheets().get(“Data”);
//Create an object for ImageOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
//imgOptions.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
PageSetup pageSetup = worksheet.getPageSetup();
//Specifying the cells range (from A1 cell to T35 cell) of the print area
pageSetup.setPrintArea(“A1:AD41”);
worksheet.autoFitRows();
worksheet.getPageSetup().setLeftMargin(0);
worksheet.getPageSetup().setRightMargin(0);
worksheet.getPageSetup().setTopMargin(0);
worksheet.getPageSetup().setBottomMargin(0);
//If you want entire sheet as a singe image
imgOptions.setOnePagePerSheet(true);
//Set the image type
imgOptions.setImageFormat(ImageFormat.getPng());
//Create a SheetRender object for the target sheet
SheetRender sr = new SheetRender(worksheet, imgOptions);
//Generate an image for the worksheet
sr.toImage(0, “C:/Suresh/AsposeReports/MBM33_New” + “.png”);
System.out.println("*********************************************");
System.out.println(" JPEG Report Generation COMPLETED “);
System.out.println(”*********************************************");
//Instantiate Presentation class that represents PPTX file
Presentation pres = new Presentation();
ISlide sld = pres.getSlides().get_Item(0);
IPPImage imgx =null;
try{
imgx = pres.getImages().addImage(new FileInputStream(new File(“C:/Suresh/AsposeReports/MBM33_New.png”)));
}
catch(IOException e){}
IPictureFrame pf=sld.getShapes().addPictureFrame(ShapeType.Rectangle, 0, 0, imgx.getWidth(), imgx.getHeight(), imgx);
//Setting relative scale width and height
pf.setRelativeScaleHeight(1.0f);
pf.setRelativeScaleWidth(0.9f);
//Add Picture Frame with height and width equivalent of Picture
//sld.getShapes().addPictureFrame(ShapeType.Rectangle, 50, 150, imgx.getWidth(), imgx.getHeight(), imgx);
//Write the PPTX file to disk
pres.save(“C:/Suresh/AsposeReports/MBM33.pptx”, SaveFormat.Pptx);
} catch (Exception e) {
e.printStackTrace();
}