如何使用Java创建空白word文档。
以下是使用Java创建空白word文档的程序。
import java.io.File;
import java.io.FileOutputStream;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
public class CreateWordDocument {
public static void main(String[] args)throws Exception {
//Blank Document
XWPFDocument document = new XWPFDocument();
//Write the Document in file system
FileOutputStream out = new FileOutputStream (
new File("C:/poiword/createdocument.docx"));
document.write(out);
out.close();
System.out.println("createdocument.docx written successully");
}
}