设为首页 加入收藏

TOP

利用POI插件导入excel怎样读取合并行数据?
2014-11-23 19:01:36 来源: 作者: 【 】 浏览:14
Tags:利用 POI 插件 导入 excel 怎样 读取 并行 数据

\

\

像这样的excel格式,我导入excel时,怎么去解析这个文件?< http://www.2cto.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+yOe5+8D708PV/bOjtcS3vcq9yKW2wcihtaXUqiYjMjY2ODQ7o6zWu8TctsHIobrPsqLQ0NbQtcS12tK70NC1xMr9vt2jrMbky/vQ0M6qv9WhozwvcD4KPHA+y/nS1LHY0OvSqtaqtcC6z7Ki0NDKx7TTxMTQ0L+qyryjrMTE0NC94cr4o6zV4tCp0NC1xCYjMjA1NDA7trzIpbbByKHV4rj2us+yotDQ1tC1xLXa0rvQ0Mr9vt2hozwvcD4KPHA+ssnIobXEt73Kvcjnz8KjujwvcD4KPHA+PC9wPgo8cHJlIGNsYXNzPQ=="brush:java;">/** * 合并单元格处理,获取合并行 * @param sheet * @return List */ public List getCombineCell(Sheet sheet) { List list = new ArrayList (); //获得一个 sheet 中合并单元格的数量 int sheetmergerCount = sheet.getNumMergedRegions(); //遍历合并单元格 for(int i = 0; i listCombineCell,Cell cell,Sheet sheet) throws Exception { int firstC = 0; int lastC = 0; int firstR = 0; int lastR = 0; String cellValue = null; for(CellRangeAddress ca:listCombineCell) { //获得合并单元格的起始行, 结束行, 起始列, 结束列 firstC = ca.getFirstColumn(); lastC = ca.getLastColumn(); firstR = ca.getFirstRow(); lastR = ca.getLastRow(); if(cell.getRowIndex() >= firstR && cell.getRowIndex() <= lastR) { if(cell.getColumnIndex() >= firstC && cell.getColumnIndex() <= lastC) { Row fRow = sheet.getRow(firstR); Cell fCell = fRow.getCell(firstC); cellValue = getCellValue(fCell); break; } } else { cellValue = ""; } } return cellValue; }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇SpringMVC(三)――其他知识 下一篇C指针原理(95)-汇编基础(2)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: