posts - 27,comments - 2,trackbacks - 0
          <2013年7月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          常用鏈接

          留言簿

          隨筆檔案

          文章檔案

          搜索

          •  

          積分與排名

          • 積分 - 18100
          • 排名 - 1845

          最新評論

          閱讀排行榜

          評論排行榜

          簡單的代碼:
          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)  編輯  收藏

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


          網站導航:
           
          主站蜘蛛池模板: 石景山区| 灌南县| 浠水县| 正镶白旗| 东源县| 崇礼县| 鹤庆县| 牙克石市| 汶川县| 紫阳县| 普兰店市| 湖南省| 揭西县| 镇平县| 陕西省| 克什克腾旗| 萨嘎县| 鸡泽县| 永登县| 子洲县| 东平县| 通河县| 依兰县| 清原| 灵山县| 全椒县| 宿松县| 拜城县| 稻城县| 荥阳市| 宣武区| 嘉黎县| 临海市| 旬阳县| 涞水县| 荆门市| 贵港市| 晴隆县| 张家港市| 合江县| 开封县|