poi读取Excel,怎么判断这个单元格是否是合并?
1个回答
展开全部
//判断表中是否含有合并单元格
public boolean hasMerged() {
return sheet.getNumMergedRegions() > 0 ? true : false;
}
// 判断指定区域内是否含有合并单元格
public boolean hasMerged(Region region) {
for (int row = region.getRowFrom(); row < region.getRowTo(); row++) {
for (short col = region.getColumnFrom(); col < region.getColumnTo(); col++){
for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
Region r = sheet.getMergedRegionAt(i);
if (r.contains(row, col)) {
return true;
}
}
}
}
return false;
}
public boolean hasMerged() {
return sheet.getNumMergedRegions() > 0 ? true : false;
}
// 判断指定区域内是否含有合并单元格
public boolean hasMerged(Region region) {
for (int row = region.getRowFrom(); row < region.getRowTo(); row++) {
for (short col = region.getColumnFrom(); col < region.getColumnTo(); col++){
for (int i = 0; i < sheet.getNumMergedRegions(); i++) {
Region r = sheet.getMergedRegionAt(i);
if (r.contains(row, col)) {
return true;
}
}
}
}
return false;
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询