POI吗?请问怎样读取Excel文件中合并单元格的内..." src="/uploads/tu/436.jpg" style" />
乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 用<em>poi</em>读取excel文件时,合并的单元格如何让每个单元格都...-poi 读

用<em>poi</em>读取excel文件时,合并的单元格如何让每个单元格都...-poi 读

作者:乔山办公网日期:

返回目录:excel表格制作







//poi-3.7.jar
/**
* 合并单元格处理--加入list
*
* @param sheet
* @return
*/
public void getCombineCell(HSSFSheet sheet, List<CellRangeAddress> list) {
// 获得一个 sheet 中合并单元格的数量
int sheetmergerCount = sheet.getNumMergedRegions();
// 遍历合并单元格
for (int i = 0; i < sheetmergerCount; i++) {
// 获得合e5a48de588b67a686964616f337并单元格加入list中
CellRangeAddress ca = sheet.getMergedRegion(i);
list.add(ca);
}
}

/**
* 判断单元格是否为合并单元格
*
* @param listCombineCell
* 存放合并单元格的list
* @param cell
* 需要判断的单元格
* @param sheet
* sheet
* @return
*/
public static Boolean isCombineCell(List<CellRangeAddress> listCombineCell,
HSSFCell cell, HSSFSheet sheet) {
int firstC = 0;
int lastC = 0;
int firstR = 0;
int lastR = 0;
for (CellRangeAddress ca : listCombineCell) {
// 获得合并单元格的起始行, 结束行, 起始列, 结束列
firstC = ca.getFirstColumn();
lastC = ca.getLastColumn();
firstR = ca.getFirstRow();
lastR = ca.getLastRow();
if (cell.getColumnIndex() <= lastC&& cell.getColumnIndex()>= firstC) {
if (cell.getRowIndex() <= lastR && cell.getRowIndex() >= firstR) {
return true;
}
}
}
return false;
}
}

相关阅读

  • <em>Java</em>利用<em>POI导入excel</em>表格

  • 乔山办公网excel表格制作
  • 参考答案   4.如果现在这个时代能出全才,那便是应试教育的幸运和这个时代的不幸。如果有,他便是人中之王,可惜没有,所以我们只好把“全”字人下的“王”给拿掉。时代需要
关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网