嵌套以循环打印Excel列中的最后一个值

时间:2019-04-29 04:29:12

标签: java

我尝试过使用while循环哈希从地图上获取详细信息,但无法按预期进行(见下文)。

      // Mapping for fetching data and putting into excel       
      m1= (Map) M2.get(appkey);
      devkeys = m1.keySet();
      for (String devkey : devkeys) {
          m0 = (Map) m1.get(devkey);
          browkeys = m0.keySet();
          for (String browkey : browkeys) {
                System.out.println("Total Count = " + m0.get(browkey) + " " + m1.get(devkey) +  " " + browkey + " " + devkey + " " + appkey );
                browsercnt = (Integer) m0.get(browkey); 
                Integer cellnuma = 0;
                Integer rownum = 0 ;
                Row row=null;
                if ((sheet.getRow(rownum) != null) ||(sheet.getRow(rownum) == null)) {
                      row = sheet.createRow(rownum);
                      for (cellnuma = 0; cellnuma <= browkeys.size(); cellnuma++) {

                            Cell cell = row.getCell(cellnuma);
                            cell = row.createCell(cellnuma);
                            cell.setCellValue(browkey);
                      }
                }

          }
      }

我对Excel的期望

     Column 0   Column 1   Column 2

行0浏览器1浏览器2浏览器3

我在Excel中的代码输出

     Column 0   Column 2   Column 3

第0行Browser3 Browser3

0 个答案:

没有答案