Reading Data from Table

Hi All,

thanks for helping me a lot.

right now i am trying to read one table from a slide and and get the data from a slide and in specific condition change the data and then save the slide.

can you guys please help me. i tried to read all the shapes of slide but i find table is not the object of shape, so not able to read it so please help me on this thanks.

Thanks & Regards
Setu Agrawal

Hey Guys,

i am in kind of urgency if you guys can help me it will be great.


Thanks & Regards
Setu Agrawal

Hi Setu,

Thanks for considering Aspose.Slides.

We are sorry for the delayed response. Please follow this link in documents section to how to access the table in the PPT slides.

We are sorry for your inconvenience,

Hi Mudassir,

thanks for helping me.

i tried this thing but in this way one issue is there, when we try to read one slide which is generated through normal microsoft Power point tool its reading table as a Groupshape, its only reading those table which are created by Aspose only so can you please help me in reading a table from a slide which created by MicroSoft PPT tool.

my peace of code is :

public static void processSlide(Slide slide) throws Exception {
int size = slide.getShapes().size();
System.out.println("slide no “+slide.getSlideId()+” :: slide "+slide.getSlidePosition());
for(int i=0;i<size;i++) {
Shape shape = slide.getShapes().get(i);
System.out.println("Name of shape “+shape.getName() +” :: object : "+shape);
if(shape instanceof Table) {
System.out.println("shape table found "+i);
}
if(shape instanceof TextFrame) {
System.out.println("shape TextFrame found "+i);
}
if(shape instanceof Rectangle) {
System.out.println("shape Rectangle found "+i);
}
if(shape instanceof GroupShape) {
System.out.println("shape GroupShape found "+i);
}

}
}


Consol out put is :

Name of shape Rectangle 2 :: object : com.aspose.slides.Rectangle@15093f1
shape Rectangle found 0
Name of shape :: object : com.aspose.slides.GroupShape@19836ed
shape GroupShape found 1
Name of shape :: object : com.aspose.slides.GroupShape@3e0ebb
shape GroupShape found 2
Name of shape :: object : com.aspose.slides.GroupShape@39443f
shape GroupShape found 3
slide no 1565 :: slide 2
Name of shape Rectangle 1 :: object : com.aspose.slides.Rectangle@1afae45
shape Rectangle found 0
Name of shape :: object : com.aspose.slides.GroupShape@da4b71
shape GroupShape found 1



please help me on this.

Thanks & Regards
Setu Agrawal

Hi Mudassir,


i found one more thing if i am creating one table with Aspose in slide and if we do any editing on that table with Microsoft PPT tool and now if we are trying to read this table its not reading it.
please help me on above issue we are stuck on it, we need to find a solution for this.
if you want i can come on phone or over web chat if you want.


Thanks & Regards
Setu Agrawal

Hello Setu,

We are extremely sorry for getting to you so late but we were resolving your query. Please use the code snippet below that reads the the contents from a PPT table, no matter whether it is generated through Aspose.Slides or modified and created through MS PowerPoint 2007. I have also uploaded the sample PPT file for your reference.

[Java]

try
{

Presentation pres=new Presentation(new FileInputStream(new File("d://ppt//modified.ppt")));

Slide sl = pres.getSlideByPosition(2);

Shape shp=sl.getShapes().get(0);
String st="";

if(shp instanceof GroupShape)
{
GroupShape gshp=(GroupShape)shp;

if(gshp instanceof Table)
{
Table tab=(Table)gshp;
st= tab.getCell(0,0).getTextFrame().getParagraphs().get(0).getPortions().get(0).getText();

TextFrame tf=tab.getCell(0,0).getTextFrame();

//If text frame is not null then add some text to the cell

if(tf!=null)

st= tf.getParagraphs().get(0).getPortions().get(0).getText();

}
}

}

catch(IOException e)
{
System.out.println(e.toString());
}

Thanks and Regards,

Hi Mudassir,

i am using your code snippet and your attached ppt. but still i am not able to read the table i think may be i m having some Aspose version issue i m using older one. please check i m attaching my Aspose jar file and again writing the code and console output



code snippet :


package src.com.cisco.salesit.QBR.action;

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

//import com.aspose.slides.Presentation;
import com.aspose.slides.*;

public abstract class testingAspose {

public static void main(String[] args) {
testing();

}
public static void testing(){
try
{

Presentation pres=new Presentation(new FileInputStream(new File("./properties/modified.ppt")));
System.out.println(“no of slides =”+pres.getSlides().size());
for(int i = 1;i<= pres.getSlides().size();i++){
Slide sl = pres.getSlideByPosition(i);

System.out.println(“no of shapes =”+sl.getShapes().size());
for(int j=0;j<sl.getShapes().size();j++){
Shape shp=sl.getShapes().get(j);
String st="";

if(shp instanceof GroupShape)
{
GroupShape gshp=(GroupShape)shp;

System.out.println("gshp instanceof Table :: "+(gshp instanceof Table));
if(gshp instanceof Table)
{
System.out.println(“i m in”);
Table tab=(Table)gshp;
st= tab.getCell(0,0).getTextFrame().getParagraphs().get(0).getPortions().get(0).getText();

TextFrame tf=tab.getCell(0,0).getTextFrame();

//If text frame is not null then add some text to the cell

if(tf!=null)

st= tf.getParagraphs().get(0).getPortions().get(0).getText();

}
}

}
}
}

catch(Exception e)
{
System.out.println(e.toString());
}
}

}




console output

no of slides =2
no of shapes =2
gshp instanceof Table :: false
no of shapes =1
gshp instanceof Table :: false



Please check my aspose version also and please replace format to jar in place of zip in attached file.

Thanks & regards
Setu Agrawal
+919901455684

Hi Mudassir,

first of all i am very sorry, because i used older version of aspose jar file and found that issue now i have used latest one and its working fine.

and i really want to appreciate your dedication to your work.


Thanks & regards
Setu Agrawal