given an excel workbook which could contain multiple sheets and multiple charts, how can I navigate through the workbook to select a specific graph, and then embed that graph and it's supporting data in a power point slide?
what I need is for a user to see the graph when opening the presentation, but then be able to edit the supporting data as is available through regular powerpoint functionality...
Well you need to use Aspose.Cells for this purpose. Using Aspose.Cells, you can access the Excel file and particular workbook inside that. Then you can export that workbook as OLE object to any particular slide. Please follow the thread posts at link2 for further clarifications.
yes…I can navigate through a workbook using
the com.aspose.cells library, but still need to figure
out 2 things:
once I find the desired chart, which could be one
of many in a workbook or even in a worksheet, how can that specific
chart be identified as the chart which appears on the slide?
must I extract it to a new workbook?
I’ve managed to successfully embed a chart in a slide
and create a picture for the chart…the problem is the
picture colors don’t match the chart colors…and as soon
as the chart is activated in the slide, the powerpoint application
screen bounces around a bit and the picture pretty
much disappears forever…is there a way to just display
the chart without the extra picture? or at least make them
an exact match?
For the first part of your question about showing specific chart in a
slide, after investigation I think it is required to copy the desired chart
to a new workbook or worksheet. Following is the Code sample for your reference:
Workbook
wb = new Workbook();
wb.open("template.xls");
Chart
chartSrc = srcSheet.getCharts().getChart(0); //assume it is
the desired chart to be shown in
slides Worksheet chartSheet
= wss.addSheet(SheetType.CHART);
wss.setActiveSheet(chartSheet); //make this chart sheet
active so when embed it into slides the chart will be
shown
chartSheet.getShapes().addCopy(chartSrc.getChartShape());
when opening the completed powerpoint presentation the chart appears and has the correct data, but the colors are incorrect...
activating the chart with either a right-click or a double-click will successfully open it for editing, and it also refreshes the chart such that the colors display correctly...
so...the question is -- how can I make the chart colors appear correctly without forcing the user to activate the chart?
Please try the attached version of Aspose.Cells for Java. If you still find the image’s color issue, kindly post your generated excel file (containing the chart) or sample code to create the chart and its output image here, we will check your issue soon.
We are using Aspose Slides for Dot Net. As part of embedding excel chart on the powerpoint slide, with the following code,
Bitmap imgChart = new Bitmap(wb.Worksheets[0].Charts[0].ToImage());
var pic = new Aspose.Slides.Picture(presentation, imgChart); int picId = presentation.Pictures.Add(pic); oleFrame.PictureId = picId;
produces the chart image of poor quality. But activating the chart with either a right-click or a double-click fixes the blurry effect. To be noted, No “ImageOrPrintOptions” attributes improves the quality. (file attached)
So, my question is, how I can achieve the proper look and feel of the chart without forcing the user to activate the chart.
As I couldn’t update the image in a programmatic way, so I used Macro on Open event of the presentation. I took help from Technical Articles for Aspose Updating OLE objects automatically using MS
PowerPoint Add-In But I had to modify the code like this to make it work:
Sub Auto_open() Dim oShape As Shape Dim oSlide As Slide
For Each oSlide In ActivePresentation.Slides For Each oShape In oSlide.Shapes
If oShape.Type = msoEmbeddedOLEObject Then
Set oChart = oShape.OLEFormat.Object.charts(1) With oChart .ChartArea.AutoScaleFont = False End With Set oChart = Nothing End If Next oShape Next oSlide End Sub