package com.th.demo.tools;

import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;

import javax.servlet.http.HttpServletResponse;
import java.io.*;

/**
 * Created by dell on 2018-06-12.
 */
public class ExportWordTools {


    public static void exportSendGoodsWord(  XWPFDocument document,HttpServletResponse response) {

        try {

            OutputStream out = null;
            response.setContentType("application/msword");
            response.setHeader("Content-disposition", "attachment;filename=" + new String("test.docx".getBytes("UTF-8"), "ISO8859-1"));
            out = response.getOutputStream();




            document.write(out);
            out.close();
            System.out.println("create_table document written success.");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
