乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      poi.hwpf 操作word 越詳細(xì)越好

       三十的狼 2018-06-14
      /***
           * 實(shí)現(xiàn)Word模板讀取替換內(nèi)容輸出
           * @param filePath 模板路徑
           * @param haderMap 頁(yè)眉數(shù)據(jù)
           * @param bodyMap  內(nèi)容數(shù)據(jù)
           * @param footMap  頁(yè)腳數(shù)據(jù)
           */
          public static void readwriteWord(String filePath, Map<String,String> haderMap,Map<String ,String> bodyMap,Map<String,String> footMap){
              //讀取word模板
              FileInputStream in = null;
              try {
                  in = new FileInputStream(new File(filePath));
              catch (FileNotFoundException e1) {
                  e1.printStackTrace();
              }
              HWPFDocument hdt = null;
              try {
                  hdt = new HWPFDocument(in);
              catch (IOException e1) {
                  e1.printStackTrace();
              }
              //讀取word頁(yè)眉內(nèi)容
              Range harderRange= hdt.getHeaderStoryRange();
              //替換word頁(yè)眉內(nèi)容
              for(Map.Entry<String, String> entry:haderMap.entrySet()){
                  harderRange.replaceText("${" + entry.getKey() + "}", entry.getValue());           
              }
               
              //讀取頁(yè)腳內(nèi)容
              Range footRange=hdt.getFootnoteRange();
              //替換頁(yè)腳內(nèi)容
              for(Map.Entry<String,String> entry:footMap.entrySet()){
                  footRange.replaceText("${" + entry.getKey().trim() + "}", entry.getValue());           
              }
               
              //讀取word文本內(nèi)容
              Range bodyRange = hdt.getRange();
              //替換文本內(nèi)容   
              for (Map.Entry<String,String> entry: bodyMap.entrySet()) {
                  bodyRange.replaceText("${" + entry.getKey() + "}",entry.getValue());
                  
              }
               
             // PicturesTable   picturesTable=  hdt.getPicturesTable();
      //        //hdt.addPicture(bytes, XWPFDocument.PICTURE_TYPE_JPEG); 
      //        
      //        FileInputStream fis = new FileInputStream("F:\\picture\\http_imgload.jpg");
      //        //將圖片添加到xlsx文件
      //        int picinx = hdt.addPicture(fis, XWPFDocument.PICTURE_TYPE_JPEG);
      //        fis.close();
      //    
               
               
              ByteArrayOutputStream ostream = new ByteArrayOutputStream();
              String fileName = ""+System.currentTimeMillis();
              fileName += ".doc";
              FileOutputStream out = null;
              try {
                  out = new FileOutputStream("E:\\test\\"+fileName,true);
              catch (FileNotFoundException e) {
                  e.printStackTrace();
              }
              try {
                  hdt.write(ostream);
              catch (IOException e) {
                  e.printStackTrace();
              }
              //輸出字節(jié)流
              try {
                  out.write(ostream.toByteArray());
              catch (IOException e) {
                  e.printStackTrace();
              }
              try {
                  out.close();
              catch (IOException e) {
                  e.printStackTrace();
              }
              try {
                  ostream.close();
              catch (IOException e) {
                  e.printStackTrace();
              }
          }    

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多