java jxl excel导出报错 Warning: Cannot merge cells - top left and bottom right incorrectly specified

用jxl导出excel时报错Warning: Cannot merge cells - top left and bottom right incorrectly specified.

部分版本的excel由于这个错误导致导出表格样式错误.

以下是错误日志源码:

/**
 * Merges the specified cells.  Any clashes or intersections between 
 * merged cells are resolved when the spreadsheet is written out
 *
 * @param col1 the column number of the top left cell
 * @param row1 the row number of the top left cell
 * @param col2 the column number of the bottom right cell
 * @param row2 the row number of the bottom right cell
 * @return the Range object representing the merged cells
 * @exception jxl.write..WriteException
 * @exception jxl.write.biff.RowsExceededException
 */
public Range mergeCells(int col1, int row1, int col2, int row2)
  throws WriteException, RowsExceededException
{
  // First check that the cells make sense
  if (col2 < col1 || row2 < row1)
  {
    logger.warn("Cannot merge cells - top left and bottom right "+
                "incorrectly specified");
  }

  // Make sure the spreadsheet is up to size
  if (col2 >= numColumns || row2 >= numRows)
  {
    addCell(new Blank(col2, row2));
  }

  SheetRangeImpl range = new SheetRangeImpl(this, col1, row1, col2, row2);
  mergedCells.add(range);

  return range;
}

所以如果是单行合并单元格,那么row2的值应该和row1的值一致,而非0;

你可能感兴趣的:(java,java,excel,合并,jxl)