Hi Alexander,
Hi,
aspose.slides-2.6.0.0.jar
aspose-cells-7.0.2.jar
columns_1.xlsx file in attachments.
Here is sample code:
private static void addPictureFrameOle( )
{
Presentation presentation = createEmptyPresentation();
Slide slide = presentation.addEmptySlide();
String path = “columns_1.xlsx”;
Workbook workbook = null;
try
{
workbook = new Workbook( path );
}
catch( Exception e )
{
}
Chart aChart = workbook.getWorksheets().get( 0 ).getCharts().get( 0 );
ImageOrPrintOptions imageOptions = new ImageOrPrintOptions ();
imageOptions.setImageFormat( ImageFormat.getPng() );
// imageOptions.setFashion( FileFormatType.EXCEL_97_TO_2003 );
aChart.setDepthPercent( 40 );
aChart.setGapDepth( 80 );
// set size ole window in report ( rowFirst, rowLast, columnFirst, columnLast )
workbook.getWorksheets().setOleSize( 10,30,0,13 );
ByteArrayOutputStream pictureBytes = new ByteArrayOutputStream();
// convert aspose chart object to image
try
{
aChart.toImage( pictureBytes, imageOptions );
}
catch( Exception e )
{
///
}
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try
{
workbook.save( bout, FileFormatType.EXCEL_97_TO_2003 );
}
catch( Exception e )
{
e.printStackTrace();
}
InputStream inputStream = new ByteArrayInputStream( pictureBytes.toByteArray() );
// create new picture object
com.aspose.slides.Picture picture = new com.aspose.slides.Picture( presentation, inputStream );
// and add it in to presentation
int pictureId = presentation.getPictures().add( picture );
int pictureWidth = (int) (picture.getWidth() * AsposeUtility.IMAGE_SCALE_FACTOR);
int pictureHeight = (int) (picture.getHeight() * AsposeUtility.IMAGE_SCALE_FACTOR);
//int slideWidth = slide.getBackground().getWidth();
//int slideHeight = slide.getBackground().getHeight();
//int pictureX = (slideWidth / 2) - (pictureWidth / 2);
//int pictureY = (slideHeight / 2) - (pictureHeight / 2);
int pictureY = AsposeUtility.DEFAULT_TOP_MARGIN;
int pictureX = AsposeUtility.DEFAULT_TOP_MARGIN + 400;
//int pictureX = AsposeUtility.PP_DEFAUL_MARGIN_RIGHT;
OleObjectFrame oof = slide.getShapes().addOleObjectFrame( pictureX, pictureY, pictureWidth, pictureHeight, “Excel.Sheet.8”, bout.toByteArray() );
oof.setPictureId( pictureId );
// add picture old style
// slide.getShapes().addPictureFrame( pictureId, pictureX, pictureY, pictureWidth, pictureHeight );
presentation.save( “file.ppt”, com.aspose.slides.export.SaveFormat.PPT );
}
private static Presentation createEmptyPresentation()
{
Presentation presentation;
presentation = new Presentation();
presentation.addEmptySlide();
presentation.getSlides().removeAt( 0 );
Fonts fonts = presentation.getFonts();
if( fonts.size() > 0 )
{
try
{
FontEntity fontEntity = new FontEntity( presentation, fonts.get( 0 ) );
fontEntity.setFamily( (byte)0 );
fontEntity.setFontName( AsposeUtility.FONT_NAME_SEGOE );
fontEntity.setCharSet( 0 );
fontEntity.setPitch( (byte)0 );
fontEntity.setQuality( 5 );
fonts.add( fontEntity );
}
catch( IOException e )
{
throw new AnalyzerException(
“Can’t insert '” + AsposeUtility.FONT_NAME_SEGOE + “’ font into a presentation”, e );
}
}
return presentation;
}
Hi Alexander,