posts - 27,comments - 2,trackbacks - 0
          簡單的代碼:
          public static void main(String[] args) {
          try {
          File allfile = new File("f:\\excel\\total.xlsx");
          File file2 = new File("f:\\excel\\xxxxxx.xlsx");
          XSSFWorkbook h = new XSSFWorkbook(new FileInputStream(allfile));
          XSSFSheet x = h.getSheetAt(0);
          XSSFWorkbook hssfWorkbook = new XSSFWorkbook(new FileInputStream(file2));
          XSSFSheet hssfSheet = hssfWorkbook.getSheetAt(0);
          int ii = hssfSheet.getLastRowNum();//讀取的表格行數
          System.out.println(ii);
          FileOutputStream out_ = new FileOutputStream(allfile);
          for (int i = 0; i < ii; i++) {
          XSSFRow lastRow = x.createRow(x.getLastRowNum()+1);
          XSSFRow xssfRow = hssfSheet.getRow(i);
          XSSFCell xssfCell0 = xssfRow.getCell(0);
          CellStyle cellStyle0 = xssfCell0.getCellStyle();
          CellStyle newStyle0 = h.createCellStyle();
          newStyle0.cloneStyleFrom(cellStyle0);
          XSSFCell xssfCell0_ = lastRow.createCell(0);
          xssfCell0_.setCellStyle(newStyle0);
          xssfCell0_.setCellValue(xssfCell0.toString());
          XSSFCell xssfCell1 = xssfRow.getCell(1);
          CellStyle cellStyle1 = xssfCell1.getCellStyle();
          CellStyle newStyle1 = h.createCellStyle();
          newStyle1.cloneStyleFrom(cellStyle1);
          XSSFCell xssfCell1_ = lastRow.createCell(1);
          xssfCell1_.setCellStyle(newStyle1);
          xssfCell1_.setCellValue(xssfCell1.toString());
          XSSFCell xssfCell2 = xssfRow.getCell(2);
          CellStyle cellStyle2 = xssfCell2.getCellStyle();
          CellStyle newStyle2 = h.createCellStyle();
          newStyle2.cloneStyleFrom(cellStyle2);
          XSSFCell xssfCell2_ = lastRow.createCell(2);
          xssfCell2_.setCellStyle(newStyle2);
          xssfCell2_.setCellValue(xssfCell2.toString());
          XSSFCell xssfCell3 = xssfRow.getCell(3);
          CellStyle cellStyle3 = xssfCell3.getCellStyle();
          CellStyle newStyle3 = h.createCellStyle();
          newStyle3.cloneStyleFrom(cellStyle3);
          XSSFCell xssfCell3_ = lastRow.createCell(3);
          xssfCell3_.setCellStyle(newStyle3);
          xssfCell3_.setCellValue(xssfCell3.toString());
          XSSFCell xssfCell4 = xssfRow.getCell(4);
          CellStyle cellStyle4 = xssfCell4.getCellStyle();
          CellStyle newStyle4 = h.createCellStyle();
          newStyle4.cloneStyleFrom(cellStyle4);
          XSSFCell xssfCell4_ = lastRow.createCell(4);
          xssfCell4_.setCellStyle(newStyle4);
          xssfCell4_.setCellValue(xssfCell4.toString().toString());
          }
          h.write(out_);
          out_.flush();
          out_.close();
          } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          }
          }
          posted on 2013-07-19 18:02 魏文甫 閱讀(640) 評論(0)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 清新县| 同德县| 永川市| 增城市| 社旗县| 怀仁县| 上林县| 讷河市| 潍坊市| 邓州市| 宜君县| 乐亭县| 山阴县| 常熟市| 无锡市| 郸城县| 福清市| 招远市| 泰州市| 锡林郭勒盟| 万年县| 鄂托克旗| 苍溪县| 石狮市| 毕节市| 兴文县| 苏州市| 堆龙德庆县| 海林市| 湘潭市| 崇文区| 钦州市| 敦煌市| 舒城县| 华坪县| 科技| 嘉荫县| 灌南县| 株洲市| 攀枝花市| 西盟|