Class Word07Writer

java.lang.Object
org.aoju.bus.office.word.Word07Writer
All Implemented Interfaces:
Closeable, AutoCloseable

public class Word07Writer extends Object implements Closeable
Word生成器
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • destFile

      protected File destFile
      目标文件
    • isClosed

      protected boolean isClosed
      是否被关闭
  • Constructor Details

    • Word07Writer

      public Word07Writer()
    • Word07Writer

      public Word07Writer(File destFile)
      构造
      Parameters:
      destFile - 写出的文件
    • Word07Writer

      public Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
      构造
      Parameters:
      doc - XWPFDocument
    • Word07Writer

      public Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc, File destFile)
      构造
      Parameters:
      doc - XWPFDocument
      destFile - 写出的文件
  • Method Details

    • getDoc

      public org.apache.poi.xwpf.usermodel.XWPFDocument getDoc()
      获取XWPFDocument
      Returns:
      XWPFDocument
    • setDestFile

      public Word07Writer setDestFile(File destFile)
      设置写出的目标文件
      Parameters:
      destFile - 目标文件
      Returns:
      this
    • addText

      public Word07Writer addText(Font font, String... texts)
      增加一个段落
      Parameters:
      font - 字体信息Font
      texts - 段落中的文本,支持多个文本作为一个段落
      Returns:
      this
    • addText

      public Word07Writer addText(org.apache.poi.xwpf.usermodel.ParagraphAlignment align, Font font, String... texts)
      增加一个段落
      Parameters:
      align - 段落对齐方式ParagraphAlignment
      font - 字体信息Font
      texts - 段落中的文本,支持多个文本作为一个段落
      Returns:
      this
    • addPicture

      public Word07Writer addPicture(File picFile, int width, int height)
      增加图片,单独成段落
      Parameters:
      picFile - 图片文件
      width - 宽度
      height - 高度
      Returns:
      this
    • addPicture

      public Word07Writer addPicture(InputStream in, PicType picType, String fileName, int width, int height)
      增加图片,单独成段落,增加后图片流关闭,默认居中对齐
      Parameters:
      in - 图片流
      picType - 图片类型,见Document.PICTURE_TYPE_XXX
      fileName - 文件名
      width - 宽度
      height - 高度
      Returns:
      this
    • addPicture

      public Word07Writer addPicture(InputStream in, PicType picType, String fileName, int width, int height, org.apache.poi.xwpf.usermodel.ParagraphAlignment align)
      增加图片,单独成段落,增加后图片流关闭
      Parameters:
      in - 图片流
      picType - 图片类型,见Document.PICTURE_TYPE_XXX
      fileName - 文件名
      width - 宽度
      height - 高度
      align - 图片的对齐方式
      Returns:
      this
    • addTable

      public Word07Writer addTable(Iterable<?> data)
      增加表格数据
      Parameters:
      data - 表格数据,多行数据 元素表示一行数据,当为集合或者数组时,为一行;当为Map或者Bean时key表示标题,values为数据
      Returns:
      this
    • flush

      public Word07Writer flush() throws org.aoju.bus.core.exception.InternalException
      将Excel Workbook刷出到预定义的文件 如果用户未自定义输出的文件,将抛出NullPointerException 预定义文件可以通过setDestFile(File) 方法预定义,或者通过构造定义
      Returns:
      this
      Throws:
      org.aoju.bus.core.exception.InternalException - IO异常
    • flush

      public Word07Writer flush(File destFile) throws org.aoju.bus.core.exception.InternalException
      将Excel Workbook刷出到文件 如果用户未自定义输出的文件,将抛出NullPointerException
      Parameters:
      destFile - 写出到的文件
      Returns:
      this
      Throws:
      org.aoju.bus.core.exception.InternalException - IO异常
    • flush

      public Word07Writer flush(OutputStream out) throws org.aoju.bus.core.exception.InternalException
      将Word Workbook刷出到输出流
      Parameters:
      out - 输出流
      Returns:
      this
      Throws:
      org.aoju.bus.core.exception.InternalException - IO异常
    • flush

      public Word07Writer flush(OutputStream out, boolean isCloseOut) throws org.aoju.bus.core.exception.InternalException
      将Word Document刷出到输出流
      Parameters:
      out - 输出流
      isCloseOut - 是否关闭输出流
      Returns:
      this
      Throws:
      org.aoju.bus.core.exception.InternalException - IO异常
    • close

      public void close()
      关闭Word文档 如果用户设定了目标文件,先写出目标文件后给关闭工作簿
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • closeWithoutFlush

      protected void closeWithoutFlush()
      关闭Word文档但是不写出