错位原因--获取下一单元格错误
poi转word转HTML表格错位有两个原因org.apache.poi.hwpf.converter.AbstractWordConverter类,getNumberRowsSpanned函数,获取下一个合并单元格错误。源码显示,根据当前单元格所在位置来获取下一行对应位置的单元格,必然会造成获取到的下一单元格与当前单元格非垂直合并的行,而正确的合并单元格为获取到造成错位。
源码:
protected int getNumberRowsSpanned( Table table,
final int[] tableCellEdges, int currentRowIndex,
int currentColumnIndex, TableCell tableCell )
{
if ( !tableCell.isFirstVerticallyMerged() )
return 1;
final int numRows = table.numRows();
int count = 1;
for ( int r1 = currentRowIndex + 1; r1 < numRows; r1++ )
{
TableRow nextRow = table.getRow( r1 );
if ( currentColumnIndex >= nextRow.numCells() )
break;
// we need to skip row if he don't have cells at all
boolean hasCells = false