Java. HSSF. Apache-poi. How to modificate code

前端 未结 3 1554
無奈伤痛
無奈伤痛 2021-01-26 04:06

My data is stored in a format(look down): [-] means a blank cell, on the right may be only 10 columns, after the space. Something like this:
[string0]

3条回答
  •  生来不讨喜
    2021-01-26 04:53

    If I am clear you just want to filter your first column string and rest seperately.

    Why not you just use a simple counter for this:

     while(rowIterator.hasNext()) {
        Row row = rowIterator.next();
        String RowContent = null;
        Iterator cellIterator = row.cellIterator();
        while(cellIterator.hasNext()) {
            Cell cell = cellIterator.next();
            RowContent=RowContent+cell.toString();
        }
        //Code for saving RowContent or printing or whatever you want for text in complete row
    }
    

    RowContent will give concatenation of each cells of a single row in each iteration.

提交回复
热议问题