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

Free Support Forum - aspose.com

Excel Ole chart in PowerPoint with wrong colors

Hi,

I have made chart as Ole object, and inserted it into Excel.
At first view, ppt looks perfect.
But! When you make double click on chart in power point, in order to edit,
you will see wrong colors.

See attached power point file for real example.


How I can fix it?

Hi Alexander,


I have observed the issue in the presentation. I like to share that the colors getting changed issue is in fact not related to Aspose.Slides as it only adds the chart the as Ole frame. The rest is managed by Ole engine it self when you open the presentation in PowerPoint and edit the chart. However, for further verification, I will still request you to share the details by providing the code snippet used to create presentation, source excel files and product version of Aspose.Slides and Aspose.Cells that you have used.

Many Thanks,

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,


Thanks for sharing the added information. I have been able to reproduce the issue and an issue with ID 32058 has been created in our issue tracking system for further investigation of the issue. I still doubt that the issue is related to Ole engine it self. However, once our development team will investigate, I will share the findings with you.

We are sorry for your inconvenience,