以粗体和下划线样式写入字符串以归档 [英] Writing String to file in bold and underlined style
本文介绍了以粗体和下划线样式写入字符串以归档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个类WriteFile
,它具有方法WriteToFile
,该方法将String
写入word文档.
I have class WriteFile
which has method WriteToFile
which writes String
to word document.
WriteFile data=new WriteFile("C:/test3.doc",true);
data.writeToFile(user.saxeli+" "+user.gvari+" "+user.asaki+" "+user.swori);
如何以粗体和下划线样式将String
写入"test3.doc"?
How to write String
to "test3.doc" in bold and underlined style?
这是WriteFile类:
Here is the WriteFile class:
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class WriteFile {
private String path;
private boolean append=true;
public WriteFile(String path,boolean append){
this.path=path; this.append=append;
}
public void writeToFile(String text) throws IOException{
FileWriter write=new FileWriter(path,append);
PrintWriter print_line= new PrintWriter(write);
print_line.printf("%s"+"%n", text);
print_line.close();
}
}
推荐答案
您可以引用此::
XWPFParagraph paragraphOne = document.createParagraph();
XWPFRun paragraphOneRunOne = paragraphOne.createRun();
paragraphOneRunOne.setItalic(true);
paragraphOneRunOne.setText(text);
关注此链接:: http://tkgospodinov.com/writing-microsoft- java-with-apache-poi中的word-documents/
这篇关于以粗体和下划线样式写入字符串以归档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文