public class Word07Writer extends Object implements Closeable
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
isClosed
是否被关闭
|
protected File |
targetFile
目标文件
|
| Constructor and Description |
|---|
Word07Writer()
构造
|
Word07Writer(File targetFile)
构造
|
Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
构造
|
Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc,
File targetFile)
构造
|
| Modifier and Type | Method and Description |
|---|---|
Word07Writer |
addPicture(File picFile,
int width,
int height)
增加图片,单独成段落
|
Word07Writer |
addPicture(InputStream in,
org.apache.poi.common.usermodel.PictureType picType,
String fileName,
int width,
int height)
增加图片,单独成段落,增加后图片流关闭,默认居中对齐
|
Word07Writer |
addPicture(InputStream in,
org.apache.poi.common.usermodel.PictureType picType,
String fileName,
int width,
int height,
org.apache.poi.xwpf.usermodel.ParagraphAlignment align)
增加图片,单独成段落,增加后图片流关闭
|
Word07Writer |
addPictures(int width,
int height,
File... picFiles)
增加多张图片,单独成段落,增加后图片流关闭
|
Word07Writer |
addTable(Iterable<?> data)
增加表格数据
|
Word07Writer |
addText(Font font,
String... texts)
增加一个段落
|
Word07Writer |
addText(org.apache.poi.xwpf.usermodel.ParagraphAlignment align,
Font font,
String... texts)
增加一个段落
|
void |
close()
关闭Word文档
如果用户设定了目标文件,先写出目标文件后给关闭工作簿 |
protected void |
closeWithoutFlush()
关闭Word文档但是不写出
|
Word07Writer |
flush()
将Excel Workbook刷出到预定义的文件
如果用户未自定义输出的文件,将抛出 NullPointerException预定义文件可以通过 setTargetFile(File) 方法预定义,或者通过构造定义 |
Word07Writer |
flush(File destFile)
将Excel Workbook刷出到文件
如果用户未自定义输出的文件,将抛出 NullPointerException |
Word07Writer |
flush(OutputStream out)
将Word Workbook刷出到输出流
|
Word07Writer |
flush(OutputStream out,
boolean isCloseOut)
将Word Document刷出到输出流
|
org.apache.poi.xwpf.usermodel.XWPFDocument |
getDoc()
获取
XWPFDocument |
Word07Writer |
setTargetFile(File targetFile)
设置写出的目标文件
|
protected File targetFile
protected boolean isClosed
public Word07Writer()
public Word07Writer(File targetFile)
targetFile - 写出的文件public Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc)
doc - XWPFDocumentpublic Word07Writer(org.apache.poi.xwpf.usermodel.XWPFDocument doc,
File targetFile)
doc - XWPFDocumenttargetFile - 写出的文件public org.apache.poi.xwpf.usermodel.XWPFDocument getDoc()
XWPFDocumentXWPFDocumentpublic Word07Writer setTargetFile(File targetFile)
targetFile - 目标文件public Word07Writer addText(Font font, String... texts)
font - 字体信息Fonttexts - 段落中的文本,支持多个文本作为一个段落public Word07Writer addText(org.apache.poi.xwpf.usermodel.ParagraphAlignment align, Font font, String... texts)
align - 段落对齐方式ParagraphAlignmentfont - 字体信息Fonttexts - 段落中的文本,支持多个文本作为一个段落public Word07Writer addTable(Iterable<?> data)
data - 表格数据,多行数据。元素表示一行数据,当为集合或者数组时,为一行;当为Map或者Bean时key表示标题,values为数据TableUtil.createTable(XWPFDocument, Iterable)public Word07Writer addPicture(File picFile, int width, int height)
picFile - 图片文件width - 宽度height - 高度public Word07Writer addPicture(InputStream in, org.apache.poi.common.usermodel.PictureType picType, String fileName, int width, int height)
in - 图片流picType - 图片类型,见Document.PICTURE_TYPE_XXXfileName - 文件名width - 宽度height - 高度public Word07Writer addPicture(InputStream in, org.apache.poi.common.usermodel.PictureType picType, String fileName, int width, int height, org.apache.poi.xwpf.usermodel.ParagraphAlignment align)
in - 图片流picType - 图片类型,见Document.PICTURE_TYPE_XXXfileName - 文件名width - 宽度height - 高度align - 图片的对齐方式public Word07Writer addPictures(int width, int height, File... picFiles)
width - 图片统一宽度height - 图片统一高度picFiles - 图片列表public Word07Writer flush() throws IORuntimeException
NullPointerExceptionsetTargetFile(File) 方法预定义,或者通过构造定义IORuntimeException - IO异常public Word07Writer flush(File destFile) throws IORuntimeException
NullPointerExceptiondestFile - 写出到的文件IORuntimeException - IO异常public Word07Writer flush(OutputStream out) throws IORuntimeException
out - 输出流IORuntimeException - IO异常public Word07Writer flush(OutputStream out, boolean isCloseOut) throws IORuntimeException
out - 输出流isCloseOut - 是否关闭输出流IORuntimeException - IO异常public void close()
close in interface Closeableclose in interface AutoCloseableprotected void closeWithoutFlush()
Copyright © 2025. All rights reserved.