Thanks for your suggestions. The problem is not in the loop over the list (in java the int type is big enough and I am sure we have not run over that limit). It is the call to XTableRows.insertByIndex(...) that never returns.
The problem can be reproduced manually in Writer without running our code - create a table with a bigger number of columns, add rows so that the rows*columns is a little less than 2^16, then add some more rows so that the size will go over that value and OO will hang and keep the CPU busy without ever completing the command. Thanks for your replies, any further information will be highly appreciated. Georgy
