2

I'm using poi to read tables from MS Word 2003.

The tables in doc file has 4 columns and 100 rows,the fourth column could be empty, the others couldn't. When iterating each row to get column count, some row returns 4, while others returns 3.

My question is why some row physically having 4 columns could possibly return 3 column?Why in some time the empty column could not be counted?

The snippet:

for (int i=2;i<rowCount;i++)
{
   TableRow row = tb.getRow(i);
   int columnCount = row.numCells();
   System.out.println(columnCount);
}

My document:

my document

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Shuo
  • 333
  • 1
  • 5
  • 18
  • Try putting in print statements to give the size of the array at each line. Without seeing your code or document it's sort of hard to guide you in the right direction. – bmoran Jan 30 '12 at 02:47
  • Hey bmoran, I added my code and document,could you give me a hand? – Shuo Jan 30 '12 at 02:58

1 Answers1

2

Perhaps empty cells do not manifest on the Java side. You should do exception handling inside the loop in this case to check for errors.