2 woshiws1989 woshiws1989 于 2014.06.10 10:36 提问

POI读取excle数据后进行指定处理

我用poi读取到了excle的数据,代码如下
private static List> getSheetData(HSSFSheet sheet)
{
List dataRows = new ArrayList();
Iterator rows = sheet.rowIterator();

while (rows.hasNext()) {
  HSSFRow row = (HSSFRow)rows.next();
  Iterator cells = row.cellIterator();
  List data = new ArrayList();

  int i = 0;
  while (cells.hasNext()) {
    HSSFCell cell = (HSSFCell)cells.next();
    if (cell.getCellType() == 1)
      data.add(StringEscapeUtils.escapeXml(cell.getStringCellValue().trim()));
    else if (cell.getCellType() == 0)
      data.add(String.valueOf((int)cell.getNumericCellValue()));
    else if (cell.getCellType() == 3)
      data.add("");
    else if (cell.getCellType() == 4) {
      data.add(String.valueOf(cell.getBooleanCellValue()));
    }
  }

  dataRows.add(data);

}

return dataRows;

}
我要读取的excle如下:
ProductGroup Product Priority IsGroup
LMZ LMZ0000017 6000000 false
LMZ LMZ0000018 6000000 false
LOZ LOZ0000018 6000000 false
LOZ LOZ0000019 6000000 false
...
...
下面还有很多不同的ProductGroup
我想把读取的数据处理成
[LMZ={{LMZ00000017,600000,false},{LMZ000000018,6000000,false},LOZ={{LOZ0000018,6000000,false},{LOZ000000019,6000000,false},......}]
小弟刚学不久,求各位大神指定代码怎么写!!!1!!

Csdn user default icon
上传中...
上传图片
插入图片