java生产word文档相关的工具类

Java poi解析word文档并修改Table 实际背景:解析api.json文件,加载以docx结尾的word模板,并将处理好的数据填写进去。 阅读详情

freemark工具类

package com.odm.enterprise.utils;

import cn.afterturn.easypoi.word.WordExportUtil;
import cn.afterturn.easypoi.word.entity.MyXWPFDocument;
import cn.hutool.core.lang.Assert;
import freemarker.cache.ClassTemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.apache.commons.lang.WordUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;

import javax.annotation.PostConstruct;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;

/**
 * FreeMarkers工具类
 */
@Component
public class FreeMarkerUtil {

    private final Configuration cfg = new Configuration(Configuration.VERSION_2_3_0);

    /**
     * spring加载类时执行该方法,类似于构造函数
     *
     * @throws IOException
     */
    @PostConstruct
    public void buildConfiguration() throws IOException {
        this.cfg.setDefaultEncoding("UTF-8");
//        this.cfg.setDirectoryForTemplateLoading(new File("/Users/Desktop/template/2022-11-29/"));
//        Resource path = new DefaultResourceLoader().getResource("classpath:/template");
//        this.cfg.setDirectoryForTemplateLoading(path.getFile());
        this.cfg.setTemplateLoader(new ClassTemplateLoader(new WordUtils().getClass().getClassLoader(),"/template"));
    }


    /**
     * 创建word文档
     *
     * @param dataMap  需要填入的字段
     * @param template 模板
     * @return 生成的模板文件
     */
    public static File createDoc(Map<?, ?> dataMap, Template template) {
        String name = System.currentTimeMillis() + ".doc";
        File f = new File(name);
        try {
            Writer w = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(f), StandardCharsets.UTF_8));
            template.process(dataMap, w);
            w.close();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        return f;
    }

    /**
     * 导出word
     * <p>第一步生成替换后的word文件,只支持docx</p>
     * <p>第二步下载生成的文件</p>
     * <p>第三步删除生成的临时文件</p>
     * 模版变量中变量格式:{{foo}}
     *
     * @param templatePath word模板地址
     * @param temDir       生成临时文件存放地址
     * @param fileName     文件名
     * @param params       替换的参数
     * @param request      HttpServletRequest
     * @param response     HttpServletResponse
     */
    public static void exportWord(InputStream templatePath, String temDir, String fileName, Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) {
        Assert.notNull(templatePath, "模板路径不能为空");
        Assert.notNull(temDir, "临时文件路径不能为空");
        Assert.notNull(fileName, "导出文件名不能为空");
        Assert.isTrue(fileName.endsWith(".docx"), "word导出请使用docx格式");
        if (!temDir.endsWith("/")) {
            temDir = temDir + File.separator;
        }
        File dir = new File(temDir);
        if (!dir.exists()) {
            dir.mkdirs();
        }
        try {
            String userAgent = request.getHeader("user-agent").toLowerCase();
            if (userAgent.contains("msie") || userAgent.contains("like gecko")) {
                fileName = URLEncoder.encode(fileName, "UTF-8");
            } else {
                fileName = new String(fileName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
            }
            MyXWPFDocument doc = new MyXWPFDocument(templatePath);
            WordExportUtil.exportWord07(doc, params);
            String tmpPath = temDir + fileName;
            FileOutputStream fos = new FileOutputStream(tmpPath);
            doc.write(fos);
            // 设置强制下载不打开
            response.setContentType("application/force-download");
            // 设置文件名
            response.addHeader("Content-Disposition", "attachment;fileName=" + fileName);
            OutputStream out = response.getOutputStream();
            doc.write(out);
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            delFileWord(temDir, fileName);//这一步看具体需求,要不要删
        }
    }

    /**
     * 删除零时生成的文件
     */
    public static void delFileWord(String filePath, String fileName) {
        File file = new File(filePath + fileName);
        File file1 = new File(filePath);
        file.delete();
        file1.delete();
    }

    public static String encodeImageToBase64(File file) throws Exception {
        //将图片文件转化为字节数组字符串,并对其进行Base64编码处理
        InputStream in = null;
        byte[] data = null;
        //读取图片字节数组
        try {
            in = new FileInputStream(file);
            data = new byte[in.available()];
            in.read(data);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
            throw new Exception("图片上传失败!");
        }
        //对字节数组Base64编码
        BASE64Encoder encoder = new BASE64Encoder();
        String base64 = encoder.encode(data);
        return base64;//返回Base64编码过的字节数组字符串
    }

    public static void main(String[] args) throws UnsupportedEncodingException {
        String a = "张三";
        a = new String(a.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
//        a = URLEncoder.encode(a, "ISO_8859_1");
        System.out.println(a);
    }

    /**
     * 导出word
     *
     * @param response 响应流
     * @param title    导出的文件名称
     */
    public void export(HttpServletResponse response, Map<?, ?> map, String title, String templateName) {
        File file;
        Template freemarkerTemplate;
        try {
            freemarkerTemplate = cfg.getTemplate(templateName);
            // 调用工具类的createDoc方法生成Word文档
            file = createDoc(map, freemarkerTemplate);
            response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
            FileUtils.setAttachmentResponseHeader(response, title);
            FileUtils.writeBytes(file.getAbsolutePath(), response.getOutputStream());
            FileUtils.deleteFile(file.getAbsolutePath());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    /**
     * 渲染模板数据
     *
     * @param template 模板类
     * @param model    数据
     * @return
     */
    private String renderTemplate(Template template, Object model) {
        StringWriter result = new StringWriter();
        try {
            template.process(model, result);
        } catch (TemplateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result.toString();
    }

    /**
     * 生成文件
     *
     * @param ftlFileName ftl文件名称
     * @param data        数据
     * @param filePath    生成文件路径
     */
    public void createFile(String ftlFileName, Object data, String filePath) {
        Writer out = null;
        try {
            String result = this.renderTemplate(cfg.getTemplate(ftlFileName, "UTF-8"), data);
            File file = new File(filePath);
            if (file.exists()) {
                FileUtils.deleteFile(filePath);
            }
            FileUtils.mkdirs(filePath);
            out = new BufferedWriter(new OutputStreamWriter(
                    new FileOutputStream(filePath), StandardCharsets.UTF_8), 1024);
            out.write(result);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                try {
                    out.flush();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }


    public String getImageBase(String src) {
        if (src == null || src == "") {
            return "";
        }
        File file = new File(src);
        if (!file.exists()) {
            return "";
        }
        InputStream in = null;
        byte[] data = null;
        try {
            in = new FileInputStream(file);
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        try {
            data = new byte[in.available()];
            in.read(data);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        BASE64Encoder encoder = new BASE64Encoder();
        return encoder.encode(data);
    }

    public String getEmpAutograph(String filePath) {
        String img = null;
        if (StringUtils.isNotEmpty(filePath)) {
            InputStream in = null;
            byte[] picdata = null;
            try {
                in = new FileInputStream(filePath);
                picdata = new byte[in.available()];
                in.read(picdata);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                try {
                    in.close();
                } catch (IOException e) {

                    e.printStackTrace();
                }
            }
            BASE64Encoder encoder = new BASE64Encoder();
            img = encoder.encode(picdata);
            return img;
        } else {
            return null;
        }
    }

    public void outDocx(File documentFile, InputStream ins, String fileName,
                        HttpServletResponse response) throws IOException {
//        FtlToWordUtil.setDownloadHeader(request, response, fileName);
        response.setContentType("application/force-download");// 设置强制下载不打开
        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));//指定下载的文件名
        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");

        File docxFile = new File(fileName);
        ZipOutputStream zipout = null;
        InputStream in = null;
        InputStream is = null;

        try {
            OutputStream os = new FileOutputStream(docxFile);
            int bytesRead = 0;
            byte[] buffer2 = new byte[8192];
            while ((bytesRead = ins.read(buffer2, 0, 8192)) != -1) {
                os.write(buffer2, 0, bytesRead);
            }
            os.close();
            ins.close();

            ZipFile zipFile = new ZipFile(docxFile);
            Enumeration<? extends ZipEntry> zipEntrys = zipFile.entries();
            zipout = new ZipOutputStream(response.getOutputStream());
            int len = -1;
            byte[] buffer = new byte[1024];
            while (zipEntrys.hasMoreElements()) {
                ZipEntry next = zipEntrys.nextElement();
                is = zipFile.getInputStream(next);
                // 把输入流的文件传到输出流中 如果是word/document.xml由我们输入
                zipout.putNextEntry(new ZipEntry(next.toString()));
                if ("word/document.xml".equals(next.toString())) {
                    in = new FileInputStream(documentFile);
                    while ((len = in.read(buffer)) != -1) {
                        zipout.write(buffer, 0, len);
                    }
                    in.close();
                } else {
                    while ((len = is.read(buffer)) != -1) {
                        zipout.write(buffer, 0, len);
                    }
                    is.close();
                }
                zipout.flush();
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (is != null) {
                try {
                    is.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (zipout != null) {
                try {
                    zipout.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (docxFile != null) {
                try {
                    docxFile.delete();// 删除临时文件
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            documentFile.delete();
        }
    }


    /**
     * 生成word文件
     * @param dataMap 数据
     * @param ftlName ftl模板名
     * @param wordName word文件名
     * @return
     */
    public File createDoc(Object dataMap,String ftlName,String wordName) {
        // 设置模本装置方法和路径,FreeMarker支持多种模板装载方法。可以重servlet,classpath,数据库装载,
        Template t = null;
        try {
            //要装载的模板
            t = cfg.getTemplate(ftlName);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if(t==null){
            return null;
        }
        // 输出文档名称
        File outFile = new File(wordName);
        Writer out =null;

        try {
            out =new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)));
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        if(out==null){
            return null;
        }
        try {
            t.process(dataMap, out);
            out.close();
        } catch ( IOException | TemplateException e) {
            e.printStackTrace();
        }
        return outFile;
    }

    /**
     * 导出word文档,响应到请求端
     *
     * @param tempName,要使用的模板
     * @param docName,导出文档名称
     * @param dataMap,模板中变量数据
     * @param resp,HttpServletResponse
     */
    public boolean exportDoc(String tempName, String docName, Map<?, ?> dataMap, HttpServletResponse resp) throws Exception {
        boolean status = false;
        ServletOutputStream sos = null;
        InputStream fin = null;
        if (resp != null) {
            resp.reset();
        }
        Template t = null;
        try {
            // tempName.ftl为要装载的模板
            t = cfg.getTemplate(tempName);
            t.setEncoding("utf-8");
        } catch (IOException e) {
            e.printStackTrace();
        }

        // 输出文档路径及名称 ,以临时文件的形式导出服务器,再进行下载
        String name = "temp" + (int) (Math.random() * 100000) + ".doc";
        File outFile = new File(name);
        Writer out = null;
        try {
            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), StandardCharsets.UTF_8));
            status = true;
        } catch (Exception e1) {
            e1.printStackTrace();
        }

        try {
            t.process(dataMap, out);
            out.close();
        } catch (TemplateException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            fin = new FileInputStream(outFile);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        // 文档下载
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("application/msword");
        docName = new String(docName.getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1);
        resp.setHeader("Content-disposition", "attachment;filename=" + docName + ".doc");
        try {
            sos = resp.getOutputStream();
        } catch (IOException e) {
            e.printStackTrace();
        }
        byte[] buffer = new byte[512]; // 缓冲区
        int bytesToRead = -1;
        // 通过循环将读入的Word文件的内容输出到浏览器中
        try {
            while ((bytesToRead = fin.read(buffer)) != -1) {
                sos.write(buffer, 0, bytesToRead);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (fin != null)
                try {
                    fin.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            if (sos != null)
                try {
                    sos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            if (outFile != null)
                outFile.delete(); // 删除临时文件
        }
        return status;
    }
}

Https文件地址转base64

package com.odm.enterprise.utils.image;

import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;

import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;

/**
 * @author bluekingzmm
 * @desc
 * @date 2022年11月25日
 */
@Component
public class HttpRequestUtil {

    //https的
    public static String httpsRequest(String requestUrl, String requestMethod, String outputStr) {

        // StringBuffer buffer = new StringBuffer();
        byte[] data = null;

        try {
            // 创建SSLContext对象,并使用我们指定的信任管理器初始化
            TrustManager[] tm = {new MyX509TrustManager()};
            SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");
            sslContext.init(null, tm, new java.security.SecureRandom());
            // 从上述SSLContext对象中得到SSLSocketFactory对象
            SSLSocketFactory ssf = sslContext.getSocketFactory();

            URL url = new URL(requestUrl);
            HttpsURLConnection httpUrlConn = (HttpsURLConnection) url.openConnection();
            httpUrlConn.setSSLSocketFactory(ssf);

            httpUrlConn.setDoOutput(true);
            httpUrlConn.setDoInput(true);
            httpUrlConn.setUseCaches(false);
            // 设置请求方式(GET/POST)
            httpUrlConn.setRequestMethod(requestMethod);

            if ("GET".equalsIgnoreCase(requestMethod))
                httpUrlConn.connect();

            // 当有数据需要提交时
            if (null != outputStr) {
                OutputStream outputStream = httpUrlConn.getOutputStream();
                // 注意编码格式,防止中文乱码
                outputStream.write(outputStr.getBytes(StandardCharsets.UTF_8));
                outputStream.close();
            }

            // 将返回的输入流转换成字符串
            InputStream inputStream = httpUrlConn.getInputStream();
            // InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
            // BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            byte[] buffers = new byte[1024];
            //每次读取的字符串长度,如果为-1,代表全部读取完毕
            int len = 0;
            while ((len = inputStream.read(buffers)) != -1) {
                outStream.write(buffers, 0, len);
            }
            inputStream.close();
            data = outStream.toByteArray();

            // 释放资源
            inputStream.close();
            inputStream = null;
            httpUrlConn.disconnect();
            //jsonObject = JSONObject.fromObject(buffer.toString());
        } catch (Exception ce) {
            System.out.println(ce.getMessage());
        }

        BASE64Encoder encoder = new BASE64Encoder();
        if (data == null) {
            return " ";
        }
        return encoder.encode(data);

    }

    //http的
    public static String getImageStrFromUrl(String imgURL) {
        byte[] data = null;
        HttpURLConnection conn = null;
        try {
            URL url = new URL(imgURL);
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setConnectTimeout(5 * 1000);
            conn.setReadTimeout(5 * 1000);
            InputStream inStream = conn.getInputStream();
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            //每次读取的字符串长度,如果为-1,代表全部读取完毕
            int len = 0;
            while ((len = inStream.read(buffer)) != -1) {
                outStream.write(buffer, 0, len);
            }
            inStream.close();
            data = outStream.toByteArray();

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

        } finally {
            if (conn != null) {
                conn.disconnect();
            }
        }

        BASE64Encoder encoder = new BASE64Encoder();
        if (data == null) {
            return "";
        }
        return encoder.encode(data);
        //String base64Image = Base64.getEncoder().encodeToString(data);
        //return base64Image;
    }

    public static void main(String[] args) {
        String get = httpsRequest("https://odm-b.oss-cn-shanghai.aliyuncs.com/odmfile/截屏2022-10-28 16.56.44eb0fb1f176474a7394bbf42ab7987738.png", "GET", null);
        System.out.println(get);
    }
}
Java 使用word模板创建word文档报告教程 上面是java 利用word模板生成的一个word报告文档,利用的是第三方类库Poi-tl 是实现的。poi-tl网址,之前也用过其他几种生成word的方式,比如,直接用Apache POI去生成等,不过都比较麻烦一点,最后比较之后选择了用这个类库。下面给大家上代码教程。 阅读详情

相关推荐

Java工具类:word内容文本替换

不好用请移至评论区揍我 原创代码,请勿转载,谢谢!

954L 2349

11.java程序员必知必会类库之word处理库

正常业务中,可能涉及到和合作方签约电子合同,此时,我们需要先设计合同模板,维护固定内容,将可变的内容通过占位符替代,等签章的时候,生成pdf,然后可以根据设计的合同章的坐标,调用签章系统盖电子章。

wlyang666的博客 3273

wordUtil.java

一个小项目,用来随机抽空任何单词,五个字母一下抽空一个,六到十个字母抽空两个,十到十五个字母抽空三个,五个字母以上抽空四个,不重复,抽空再次抽取

java word 数据填充_WordUtil 读取word模板文件,填充数据并写入文档

按照word模板文件填充数据并下载还是挺有用的,下载的word文件可以编辑(填写信息等),如果想要下载的文档不可编辑则使用pdf文件下载即可。HWPFDocument read(File source),读取模板文件,HWPFDocument是poi对word的封装对象replace(HWPFDocument doc, Map replaces),替换部分文字table(HWPFDocument ...

weixin_31971181的博客 1920

细说STM32单片机SPI-Flash芯片的FatFS移植及其应用实例详解

本文以开发板上的SPI-Flash芯片W25Q16为媒介详细介绍CubeMX中FatFS各个参数的意义和设置,分析生成的代码中FatFS各个文件的作用和关联,完成针对W25Q16的硬件访问层的移植。继续使用旺宝红龙开发板STM32F407ZGT6 KITV1.0。

wenchm的博客 1661

java 生成 word 文档的多种方法(三)

这篇文章给大家介绍java  通过POI技术生成word ,这种实现方式项目中也很常用,比如生成常用表格,报表等。废话少说,下面就给大家详细介绍实现原理! A、word文档正文段落概述: 一个word文档包含多个段落,一个段落包含多个Runs,一个Runs包含多个Run,Run是文档的最小单位 获取所有段落:List&lt;XWPFParagraph&gt; paragraphs = wor...

nandao158的博客 2万+

从零开始:用Python搭建你的第一个加密货币量化交易机器人(附完整代码)

本文详细介绍了如何使用Python从零开始搭建一个加密货币量化交易机器人,涵盖环境准备、交易所API连接、基础交易策略实现、回测系统构建以及实盘部署等关键步骤。通过完整的代码示例,帮助读者快速掌握数字货币量化交易的核心技术,适合有一定编程基础的投资者入门。

weixin_30415113的博客 472

【Java处理word文档】

java处理word文档,实现word段落生成、word表格生成、word超链接处理等功能。

weixin_39538035的博客 4344

FPGA开发者必看:如何用SATA3.0主机控制器IP实现高速存储扩展(附Xilinx实测数据)

本文为FPGA开发者提供了基于SATA3.0主机控制器IP核的高速存储方案设计与优化指南。通过详细解析IP核架构、Xilinx FPGA平台集成实战及性能优化技巧,帮助开发者实现接近理论极限的540MB/s数据传输速度。文章还包含常见问题解决方案和高级应用场景拓展,是硬件工程师提升存储性能的必备参考。

weixin_30632089的博客 118

运放偏置电路设计:如何精准计算差分放大器的电压偏移量

本文深入解析了差分放大器偏置电路的设计原理与精准计算方法,重点阐述了如何通过引入参考电压实现信号电压偏移,以适应单电源ADC的输入范围。文章结合实战案例,详细推导了偏移电压公式,并强调了电阻匹配、运放选型及PCB布局对精度和共模抑制比的关键影响,帮助硬件工程师避免常见设计陷阱。

weixin_29288313的博客 646

Java处理markdown格式内容转换为word文档

web富文本markdown内容转换成word文档提供导出下载

小蜜蜂1010的博客 9297

Cadence学习之路:什么是PCB工艺的正片与负片

正片??负片??Flash焊盘的创建与使用

qq_46757048的博客 4252

XWPFDocument导出Word文档简单操作

XWPFDocument

.鞭指云端.的技术博客 1万+

DeepSeek R1-32B医疗大模型的完整微调实战分析(全码版)

【代码】DeepSeek R1-32B医疗大模型的完整微调实战指南(全码版)

AllenLV的博客 5109

【AI智能体】Spring AI Tool 从使用到实战详解

Spring AI Tool

congge 5871

Java poi 生成word文档并下载

我使用的是Springboot框架开发的。首先需要在pom.xml文件中引入以下maven包: <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifactId> ...

郄梦岩的博客 2315

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

Java数据,导出word文档

读取word模板,替换表达式里面的数据

派大星的博客 2182

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Java-POI替换Word模板文档中的变量,生成Word文档

第一步:在项目中导入POI的jar包,以及相关的jar包。 所需的jar包列表: 下载地址:http://download.csdn.net/download/qq_34908167/10046670 第二步:建立util工具类。 public class DocxUtil{ /** * @Description: 将t中的字段转换成替换模板需要的数据${字...

象话的博客 1万+

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

java word模板 变量,Java-POI替换Word模板文档中的变量,生成Word文档

第一步:在项目中导入POI的jar包,以及相关的jar包。所需的jar包列表: 下载地址:http://download.csdn.net/download/qq_34908167/10046670第二步:建立util工具类。public class DocxUtil{/*** @Description: 将t中的字段转换成替换模板需要的数据${字段}-->字段值* 在word模板...

weixin_39783149的博客 1300

word与java文档相关的api

word与java文档相关的api 最近开发项目,需要读写word文档内容,并封装成一个对象。 1、引入相关jar包 注意maven导入的三个依赖必须是同一个版本,不然有可能会报错 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-scratchpad</artifactId> <vers

weixin_52027551的博客 1525

java后台导出word文档正文、表格、图片

java后台导出word文档正文、表格、图片

libralee233的博客 7917

java导出word并向导出的word中添加附件

word可以转换为xml格式(另存为的时候可以选择文件类型) 当转换为xml格式后我们可以发现在附件位置存储的其实是附件的base64字符串。 因此,我们可以在模板中添加一个附件作为占位,而后我们将模板中占位的附件base64字符串替换为我们真正需要的字符串,就能达到添加附件的效果 准备word模板 准备word模板(使用office的word,使用wps保存出来的xml格式与office不同,暂未测试wps的是否可行) 将上面的模板另存为xml格式 打开转换为xml格式的word模板,在需要动态写入的

南城的博客 5780

FreeMarker生成word文档,固定word模板

也就是必须有一个固定的模板文档是.ftl类型如果初始文件为需要手动改为:也就是所有需要替换的地方,都需要有${XX}替换。${变量名}.xml.ftl处理文本比较简单,在原文件中直接用占位符 ${} 替换即可。处在生成 word 表格时,FreeMarker 是利用列表一行一行循环填充的,而表头只会生成一次,因此我们还需手动改动一下 .ftl 文件。

鹏神丶明月天 2128

导出MySQL数据库所有库和字段注释及相关信息为word文档——工具类

接下来将为大家介绍一个自己实现的工具类,连接MySQL或Oracle数据,使用编写好的工具类将数据库所有库和表的信息导出为word文档。

qq_44723773的博客 3770

Java 实现导出 Word 文档的方法详解

在 Java 应用程序中,有时候我们需要将数据导出为 Word 文档,以便进行文档的编辑、打印或共享。本文将介绍如何使用 Java 实现导出 Word 文档的方法,帮助你灵活处理文档导出需求。在 Java 中,我们可以使用 Apache POI 库来操作 Microsoft Office 文档,包括 Word 文档。通过本文的介绍,你了解了如何使用 Java 实现导出 Word 文档的方法。你学习了使用 Apache POI 库创建 Word 文档、向文档中添加内容,并将文档导出为文件。

pleaseprintf的博客 7504
上一篇: java运用freemark生成word文档(类似论文的格式)问题总览
下一篇: java设计模式-策略模式+反射实践
bluekingzmm
博客等级 码龄11年 354粉丝 20原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值