1

Today I started using the JexcelApi and I bumped into this: When you try to get an element from a specific position, instead of using sheet.getCell(row,col) as you would normally expect, it is sheet.getCell(col,row).

So if you'd like to print your table you would have something like this:

for(int i=0;i<sheet.getRows();i++){
        for(int j=0;j<sheet.getColumns();j++)
            System.out.print(sheet.getCell(j,i).getContents()+" ");
        System.out.println();
    }

My question is why the [col,row] format? Is there a good reason why they used this instead of [row,col] as is ussualy used? Or there is no reason for this and they just went with this with no alternative reason? After using the r,c format for so much time this seems a little weird, but maybe it is more logical to use the c,r format and I just don't get why this is.

Any ideas?

Waynn Lue
  • 11,344
  • 8
  • 51
  • 76
Fofole
  • 3,398
  • 8
  • 38
  • 59

2 Answers2

1

I would expect [col,row] as in mathematics, 2-dimensional functions and points are described as [x,y] or f(x,y), ie col (x) ,row (y).

pap
  • 27,064
  • 6
  • 41
  • 46
1

Cos that's the way excel works? Eg A1, B2 - all col-row

davidfrancis
  • 3,734
  • 2
  • 24
  • 21