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

Free Support Forum - aspose.com

Re: Creating Excel Chart and Embedding it in Presentation as OLE Object


I am using your sample to embed Excel chart into presentation. The difference is that chart's type is AREA_STACKED and I would like to change foreground color of first series to RED. However, resulting chart has standard color scheme until it being activated (double-clicked) in the presentation. Other stacked chart types (e.g., BAR_STACKED) work fine.

Is there fix for that?

public static void Run() {



//Create a workbook

Workbook wb = new Workbook();

//Add an excel chart

int chartRows = 55;

int chartCols = 25;

int chartSheetIndex = AddExcelChartInWorkbook(wb, chartRows, chartCols);

//Set chart ole size

wb.setOleSize(0, chartRows, 0, chartCols);

//Get the chart image and save to stream

ByteArrayOutputStream imageStream=new ByteArrayOutputStream();

wb.getWorksheets().getSheet(chartSheetIndex).getCharts()getChart(0).toImage(imageStream, new ImageOptions());

//Save the workbook to stream

ByteArrayOutputStream bout=new ByteArrayOutputStream();


//Create a presentation

Presentation pres = new Presentation();

Slide sld = pres.getSlideByPosition(1);

//Add the workbook on slide

AddExcelChartInPresentation(pres, sld, bout.toByteArray(), imageStream.toByteArray());

//Write the presentation to disk

pres.write(new FileOutputStream("d:\\outputJ.ppt"));

}catch(Exception e){




static int AddExcelChartInWorkbook(Workbook wb, int chartRows, int chartCols)


//Array of cell names

String[] cellsName = new String[]


"A1", "A2", "A3", "A4",

"B1", "B2", "B3", "B4",

"C1", "C2", "C3", "C4",

"D1", "D2", "D3", "D4",

"E1", "E2", "E3", "E4"


//Array of cell data

int[] cellsValue = new int[]








//Add a new worksheet to populate cells with data

Worksheet dataSheet =wb.getWorksheets().addSheet();

String sheetName = "DataSheet";


//Populate DataSheet with data

int size=Array.getLength(cellsName);

for (int i = 0; i < size; i++)


String cellName = cellsName[i];

int cellValue = cellsValue[i];



//Add a chart sheet

Worksheet chartSheet = wb.getWorksheets().addSheet(SheetType.CHART);


int chartSheetIdx = chartSheet.getIndex();

//Add a chart in ChartSheet with data series from DataSheet

Chart chart = chartSheet.getCharts().addChart(ChartType.AREA_STACKED, 0, chartRows, 0, chartCols);

int first = chart.getNSeries().add(sheetName + "!A1:E1", false);


chart.getNSeries().add(sheetName + "!A2:E2", false);

chart.getNSeries().add(sheetName + "!A3:E3", false);

chart.getNSeries().add(sheetName + "!A4:E4", false);

//Set ChartSheet as active sheet


return chartSheetIdx;


static void AddExcelChartInPresentation(Presentation pres, Slide sld, byte[] wbArray, byte[] imgChart) throws Exception


com.aspose.slides.Picture pic=new com.aspose.slides.Picture(pres,new ByteArrayInputStream(imgChart));

int picId = pres.getPictures().add(pic);

int slideWidth = (int)pres.getSlideSize().getX() - 1500;

int slideHeight = (int)pres.getSlideSize().getY();

int x = 1500 / 2;

OleObjectFrame oof = sld.getShapes().addOleObjectFrame(x, 0, slideWidth, slideHeight, "Excel.Sheet.8", wbArray);



This message was posted using Page2Forum from Creating Excel Chart and Embedding it in Presentation as OLE... - Aspose.Slides for Java

Hi Zai,

I have worked with the code shared by you and have been able to observe the issue shared by you. An issue with ID 24862 has been created in our issue tracking system to further investigate and resolve the issue. This thread has also been linked with the issue so that you may be automatically notified, once the issue is resolved.

We are sorry for your inconvenience.

The issues you have found earlier (filed as SLIDESJAVA-24862) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan