afunms

          My Software,My Dream—Forge a more perfect NMS product.

          用apache.poi讀excel

          public static void main(String[] args) throws Exception {
                  POIFSFileSystem pfs 
          = new POIFSFileSystem(new FileInputStream("D:\\test_xls.xls"));             
                  HSSFWorkbook hwk 
          = new HSSFWorkbook(pfs);
                  HSSFSheet sheet 
          = hwk.getSheet("Sheet1");
                  
          try{
                      
          int lrn = sheet.getLastRowNum();
                      
          for(int r = 0;r<lrn;r++){
                          Row row 
          = sheet.getRow(r);                
                          
          int lcn = row.getLastCellNum();
                          
          for(int c = 0;c<lcn;c++){            
                              
          if(row.getCell(c)==null)
                                  System.out.println(
          "R=" + r + ",C=" + c + ":NULL");
                              
          else
                                  System.out.println(
          "R=" + r + ",C=" + c + ":" + row.getCell(c).toString());
                          }

                      }

                  }
          catch(Exception e){
                      e.printStackTrace();
                  }

              }

          posted on 2011-10-09 16:53 afunms 閱讀(267) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           

          My Links

          News

          留言簿(18)

          隨筆檔案

          相冊

          搜索

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 全南县| 华亭县| 江源县| 靖宇县| 香港| 正镶白旗| 墨玉县| 岳普湖县| 神农架林区| 福泉市| 承德县| 北辰区| 福清市| 嘉荫县| 南漳县| 民县| 尉氏县| 巨野县| 靖安县| 福州市| 阿拉善左旗| 万山特区| 兰考县| 黔西| 临沂市| 昌黎县| 莆田市| 贵定县| 太谷县| 吴旗县| 益阳市| 梁山县| 化州市| 巴东县| 师宗县| 汉沽区| 合肥市| 泸水县| 寿阳县| 高雄县| 林周县|