免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
poi.hwpf 操作word 越詳細(xì)越好
/***
     * 實現(xiàn)Word模板讀取替換內(nèi)容輸出
     * @param filePath 模板路徑
     * @param haderMap 頁眉數(shù)據(jù)
     * @param bodyMap  內(nèi)容數(shù)據(jù)
     * @param footMap  頁腳數(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頁眉內(nèi)容
        Range harderRange= hdt.getHeaderStoryRange();
        //替換word頁眉內(nèi)容
        for(Map.Entry<String, String> entry:haderMap.entrySet()){
            harderRange.replaceText("${" + entry.getKey() + "}", entry.getValue());           
        }
         
        //讀取頁腳內(nèi)容
        Range footRange=hdt.getFootnoteRange();
        //替換頁腳內(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();
        }
    }    
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
JAVA讀取WORD,EXCEL,PDF,TXT,RTF,HTML文件文本內(nèi)容的方法
Properties屬性文件
文件壓縮類
大容量XML文件解析輔助--xml批量分解 - OO - Java - JavaEye論壇
Java IO最詳解
Java中Properties類的使用
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服