Acces xlsx from pptx

Hello,


I have a pptx with an embedded chart and its related xlsx. I would like to access the xlsx with Aspose Cells to edit the data underlying the charts.

How might I do this?

Thank you.

Hi Tim,

You can access the Ole frame inside presentation slide and may access the data inside that using Aspose.Cells. Please watch this video tutorial to achieve the desired goal.

Thanks and Regards,

Thank you for your reply. I had tried this based on the documentation. Unfortunately the shapeEx is not an OleObjectFrameEx, so I can’t cast it. I’d like to emphasize the chart is embedded rather than linked, if that makes a difference. I’m able to access and manipulate the chart w/ the Slides API, but I need some Excel functionality as well.


Thank you. not

Hi Tim,

In that case I will request you to please share the source presentation and also code snippet that you are using on your end for this purpose. Please also specify which component you are using for your application. I will further investigate the issue on my end once you will share the requested data.

Thanks and Regards,

Thank you.


Here is a code snip

var pptx = new PresentationEx(PptxPath);
var shapeEx = pptx.Slides[0].Shapes[0];
Debug.Assert(shapeEx is OleObjectFrameEx, “Not an OleObjectFrameEx”);

Note that if I change OleObjectFrameEx to ChartEx in this snip, the assertion succeeds.

A sample presentation with a trivial embedded Excel chart is attached.

Best,

Tim Tabor

And I should mention that the assertion succeeds if I link the chart rather than embed it.

Hi Tim,

I have worked with the presentation shared. It has in fact chart in it and the chart type is ChartEx. Please read this article to get to know how to modify existing charts. In Aspose.Slides for .NET 5.3.0, the dependence on Aspose.Cell for .NET has been removed for charts and it can not be accessed as in case of OleFrames. Please share, if you still have any issue. For your kind reference, I have also shared the chart modified using Aspose.Slides for .NET 5.3.0.

Thanks and Regards,

Yes, I understand the chart can be modified with Aspose Slides. The question was how to access the embedded chart and data with Aspose Cells. There some things (perhaps a lot of things?) that can be done with Cells that can’t be done with Slides. I see it more of a feature than a dependency.


Thank you for looking at this.

Hi Tim,

I have created an issue with ID 29704 as a new feature request to further investigate the possibility of implementing the requested feature. This thread has been linked with the issue so that you may be automatically notified once the issue is resolved.

We are sorry for your inconvenience,

Not at all. They are all wonderful, wonderful products.

Hi Tim,


I like to share that now we have added the support for accessing the embedded Aspose.Slides chart data in Aspose.Slides for .NET 5.7.0. We have added following two new methods in ChartDataEx class:

  1. WriteWorkbookStream(MemoryStream ms)
  2. MemoryStream ReadWorkbookStream()

So, you can get a Workbook stream, work with it in Apose.Cells and upload result stream back to Slides. The following sample code will help you in this regard.


using Aspose.Slides.Pptx;
using Aspose.Slides.Pptx.Charts;
using Aspose.Cells;

PresentationEx pres = new PresentationEx(“example.pptx”);
ChartEx chart = (ChartEx) pres.Slides[0].Shapes[0];
Workbook wb = new Workbook(chart.ChartData.ReadWorkbookStream());
wb.Worksheets[0].Cells[1, 1].PutValue(150);
MemoryStream ms = new MemoryStream();
wb.Save(ms, SaveFormat.Xlsx);
chart.ChartData.WriteWorkbookStream(ms);
pres.Save(“result.pptx”,Aspose.Slides.Export.SaveFormat.Pptx);

Many Thanks,

Fabulous. Thank you.

Is this supported in the java version as well? If I have a ChartEx I would like to load the workbench. I am assume I am on the right track.

if (shapeEx instanceof ChartEx) {
ChartEx chartEx = (ChartEx) shapeEx;
dkp test = chartEx.getChartData();
}

What is the return type dkp? How do I get a workbook from this or what do I cast to?

Thanks

Hi Ashley,

Please visit this video tutorial link for your further reference.

Many Thanks,

Good Morning

Thanks for taking the time to write back. I had reviewed the video link you had send before posting the message. In the video it checks for an instance of OLEObjectFrameEx and when I do a check for that it does not enter the if condition as the object in question is a ChartEx

From reading the API documentation the ChatEx extnds the class GraphicalObjectEx and classes that implment that are ChartEx, OleObjectFrameEx, TableEx
So based on this ChartEx and OleObjectFrameEx are at the same level so I can not cast the object to OleObjectFrameEx.

I guess what I am asking is if I have a ChartEx instance how do I get at the data based on the details I explained above. In the .NET sample you can do the following

Workbook wb = new Workbook(chart.ChartData.ReadWorkbookStream());

However in java I can get the ChartData via getChartData() but there is no variable or getter method get WorkbookStream

Thanks

Hi Ashley,


Good day to you as well. Please visit this thread link for your further kind reference. Please share, if I may help you further in this regard.

Many Thanks,

Good Morning

Again thanks for you help but I am using the Java version and the methods do not seem to be the same. Here is the sample source I have so far as you can see it is very short.

I also have attached a screen shot showing the methods on chartEx instance .getCharData() method. This is why I am confused as the methods in question do not seem to exist and the return type for getChartData is “djj"

Can you provide the few lines to get the ChartDataCellFactory in java? Or point out what I am doing wrong?.

Thanks again for you help :slight_smile:

Your

Source

import java.io.File;
import java.io.FileInputStream;

import com.aspose.slides.license.AsposeLicenseException;
import com.aspose.slides.pptx.ChartEx;
import com.aspose.slides.pptx.PresentationEx;
import com.aspose.slides.pptx.ShapeEx;
import com.aspose.slides.pptx.ShapesEx;
import com.aspose.slides.pptx.SlideEx;

public class TestApplication {

public static void main(String[] args) {
try {
if (TestApplication.loadLicense(new File(”/c:/dev/aspose/Aspose.Total.Java.lic"))) {
// Instantiate PresentationEx that represents PPTX
PresentationEx pres = new PresentationEx(“c:\ashley.pptx”);
// Access first slide by its index
SlideEx slideEx = pres.getSlides().get(0);
ShapesEx shapesEx = slideEx.getShapes();
int size = shapesEx.size();
for (int i = 0; i < size; i++) {
ShapeEx shapeEx = shapesEx.get(i);
System.out.println(shapeEx.getName());
System.out.println(shapeEx.getClass().getName());
if (shapeEx instanceof ChartEx) {
ChartEx chartEx = (ChartEx) shapeEx;
chartEx.getChartData();

}

}
}
}
catch (Exception exception) {
exception.printStackTrace();
}
}

public static boolean loadLicense(File file) throws AsposeLicenseException {
try {
FileInputStream fileInputStream = new FileInputStream(file);
com.aspose.cells.License cellLicense = new com.aspose.cells.License();
cellLicense.setLicense(fileInputStream);
fileInputStream.close();

fileInputStream = new FileInputStream(file);
com.aspose.slides.License slidesLicense = new com.aspose.slides.License();
slidesLicense.setLicense(fileInputStream);
fileInputStream.close();
return true;
} catch (Exception exception) {
exception.printStackTrace();
return false;
}
}
}

Hi Ashley,


I regret to share that what you are trying to achieve through Aspose.Slides for Java is currently unenviable as chart rendering support has not be introduced in Aspose.Slides for Java yet. An issue with ID 33161 has already been added in our issue tracking system to provide chart rendering support. This feature will be introduced in Aspose.Slides for Java 3.0.0, which is scheduled for delivery by end of May, 2012. At the moment this feature is only available in Aspose.Slides for .NET that you may access the chart data. Aspose.Slides for Java only provides facility to access data of Ole frame presently, that I have shared with you previously.

We are sorry for your inconvenience,

Ok Thanks for the update. Is it possible to tell power point to use an oleframe to generate charts as end users need to design charts without development?

Thanks

Hi Ashley,

You can create excel charts and embed them in your presentation. Kindly use this article for your further reference.

Many Thanks,