本文概述
- Apache POI创建MS Word示例
请参见下面的示例,我们将创建一个单词文件srcmini.docx。
Apache POI创建MS Word示例
package poiexample;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class CreateWord {
public static void main(String[] args) throws FileNotFoundException, IOException {
XWPFDocument document = new XWPFDocument();
try(OutputStream fileOut = new FileOutputStream("srcmini.docx")) {
document.write(fileOut);
System.out.println("File created");
}catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
【apache poi创建ms word文档】输出:
This example creates a .doc extension file having name srcmini.docx.
推荐阅读
- apache poi和powerpoint
- apache poi microsoft word文档
- apache poi的注释
- apache poi样式化形状
- apache poi重写
- apache poi读取单元内容
- apache poi移位行
- apache poi页码
- apache poi概述