Cell Chart and Legend

Hi,

I like to have a chart and its legend in separate images.
Is there a way to do this? I need to add a chart and its legend
as 2 pictures in a presentation.

Much Thanks,
Hong


this is function to add chart in a presentation that I used.
public static void AddExcelChartInPresentation(Presentation presentation,
Slide slide,
Workbook wb,
int x,
int y,
int height,
int width)
throws Exception
{
int sheetInd = wb.getWorksheets().getActiveSheetIndex();
Worksheet sheet = wb.getWorksheets().get(sheetInd);

ChartCollection charts = sheet.getCharts();
Chart chart = charts.get(0);

//get chart and add graph to ppt presentation
ByteArrayOutputStream workbookByteOutStream = new ByteArrayOutputStream();

wb.save(workbookByteOutStream, SaveFormat.EXCEL_97_TO_2003);

//embed chart in slide
OleObjectFrame oof = slide.getShapes().addOleObjectFrame(x, y, width, height, AsposeConstants.OLE_CLASS_NAME_EXCEL_CHART, workbookByteOutStream.toByteArray());

ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
chart.toImage(imageStream, new ImageOrPrintOptions());


com.aspose.slides.Picture pic = new com.aspose.slides.Picture(presentation, new ByteArrayInputStream(imageStream.toByteArray()));
//obtain the aspose id (part of the process for putting the picture “on top” of embedded OLE
int picId = presentation.getPictures().add(pic);
oof.setPictureId(picId);
}

Hi,


I don’t think MS Excel allows to have plot area and its legend to be plotted on two different sheets or even two different locations. As a workaround, I think you may take two pictures of the same chart. For example, you will take the first picture with legend invisible. In the second picture, you may try to set the formatting of the chart’s plot area or make the plot area invisible etc.


Thank you.