How can I use the POI plug-in to import excel files to read merged row data?

Source: Internet
Author: User


How can I parse this file when I import an excel file in an excel format like this? <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + yOe5 + 8D708PV/combine + y/combine + merge + PC9wPgo8cHJlIGNsYXNzPQ = "brush: java;">/*** merge cells for processing, obtain the merged row * @ param sheet * @ return List */Public List GetCombineCell (Sheet sheet) {List List = new ArrayList (); // Obtain the number of merged cells in a sheet. int sheetmergerCount = sheet. getNumMergedRegions (); // traverse the merged cells 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) {// obtain the start row of the merged cell, end row, start column, and end column 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 ;}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.