Warning: fopen(/www/wwwroot/www.wendadaohang.com/data/md5_content_title/66/66e43005eb97b11e0748e98a3c21c47c.txt): failed to open stream: No space left on device in /www/wwwroot/www.wendadaohang.com/inc/function.php on line 2468

Warning: flock() expects parameter 1 to be resource, bool given in /www/wwwroot/www.wendadaohang.com/inc/function.php on line 2469

Warning: fclose() expects parameter 1 to be resource, bool given in /www/wwwroot/www.wendadaohang.com/inc/function.php on line 2475
java poi 怎么读取Excel中合并单元格的值,我读取合并单元格的第一个格有值,其他的都是空。 - 66问答网

java poi 怎么读取Excel中合并单元格的值,我读取合并单元格的第一个格有值,其他的都是空。

java poi 怎么读取Excel中合并单元格的值,我读取合并单元格的第一个格有值,其他的都是空。怎么能读取其他单元格也有值。或者推荐一个第三方插件能实现这种功能。
说明具体方法

/**
* 获取合并单元格的值
* @param sheet
* @param row
* @param column
* @return
*/
public String getMergedRegionValue(Sheet sheet, int row, int column) {
int sheetMergeCount = sheet.getNumMergedRegions();

for (int i = 0; i < sheetMergeCount; i++) {
CellRangeAddress ca = sheet.getMergedRegion(i);
int firstColumn = ca.getFirstColumn();
int lastColumn = ca.getLastColumn();
int firstRow = ca.getFirstRow();
int lastRow = ca.getLastRow();

if (row >= firstRow && row <= lastRow) {
if (column >= firstColumn && column <= lastColumn) {
Row fRow = sheet.getRow(firstRow);
Cell fCell = fRow.getCell(firstColumn);

return getCellValue(fCell);
}
}
}

return null;
}
温馨提示:答案为网友推荐,仅供参考
相似回答