java jxl excel导出报错 Warning: Cannot merge cells

来源:互联网 发布:李孝利 长相 知乎 编辑:程序博客网 时间:2024/05/01 05:38

用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;

原创粉丝点击