hi,
In my pptx file there are three tables in one slide. During iteration, the tables are retrieved in the order they are created; not in the order they appear in the slide. Could you please suggest a solution ?
regards,
Sheeba
hi,
In my pptx file there are three tables in one slide. During iteration, the tables are retrieved in the order they are created; not in the order they appear in the slide. Could you please suggest a solution ?
regards,
Sheeba
Hi Sheeba,
Thanks for the reply.
The suggested link is not a solution to my problem. Because the file might not be created by us. Any other idea?
Regards,
Sheeba
Hi Sheeba,
I am not supposed to modify the tables in the input file. Just extract details. Speed is also a constraint.
Hi Sheeba,
:-(
No.... I can't assume the layout of input file.
I wonder who is concerned with the tables in the order they are created. Getting the tables as listed will be more useful, I think. Is it difficult to achieve?
Hi Sheeba,
I regret to share that there is no other option available in this regard. Moreover, if one is interested in identifying some shape they must be identified through unique criteria. One of then is using AlternativeText to set unique name for shape. Other is to identify shapes order on the basis of position by your self. Another work around that you may try using is to identify the shapes based on contents inside table. Lets assume if you have 4 tables on the slide and each table may have some unique column that may not be present in other table. You can then identify the table on the basis of the unique column.
Thanks and Regards,
Okay, I understand.
I would like to use the second option of your suggestion, i.e identify shapes order on the basis of position. Could you please give me the details in this regard?
Thanks & Regards,
Sheeba
hi Mudassir,
I could iterate tables in the order of position on slide.
Thank you very much for your advice.
Regards,
Sheeba
Hi Sheeba,
hi mudassir,
please find the sample code below.
regards,
sheeba
private void parseTables() {
// ******* some code here to open document and get slides *********
ArrayList tables = new ArrayList();
// begin iterate shapes in slide
int nX = (int) shape.getX();
int nY = (int) shape.getY();
PageTableInfo objPageTableInfo = new PageTableInfo();
//fill objPageTableInfo with the cell contents.
tables.add(new TableInfo(nX, nY, objPageTableInfo));
// end iteration
Collections.sort(tables, tables.get(0));
}
class TableInfo implements Comparator {
int m_nX;
int m_nY;
// PageTableInfo - a user defined class that holds text from table.
PageTableInfo m_table;
public TableInfo() {
m_nX = 0; m_nY = 0; m_table = new PageTableInfo();
}
public TableInfo(int x, int y, PageTableInfo info) {
m_nX = x;
m_nY = y;
m_table = info;
}
public int getX() {
return m_nX;
}
public int getY() {
return m_nY;
}
public PageTableInfo getTable() {
return m_table;
}
@Override
public int compare(Object o1, Object o2) {
int ret = 0;
TableInfo tmp1 = (TableInfo) o1;
TableInfo tmp2 = (TableInfo) o2;
if (tmp1.getY() <= tmp2.getY()){
ret = 0;
}
else {
ret = 1;
}
return ret;
}
}