我需要使用apache poi创建一个docx文件,因为我需要将其字体设置为Latha。下面是我的代码,但是当我使用setfontfamily(" Latha")时它不起作用。 Latha是泰米尔语。
XWPFDocument document = new XWPFDocument();
FileOutputStream out = null;
try {
out = new FileOutputStream(new File("PageCounter.docx"));
} catch (FileNotFoundException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
}
try {
XWPFParagraph paragraph = document.createParagraph();
XWPFRun run = paragraph.createRun();
run.setText(replaceAll2);
run.setFontFamily("Latha");
run.setFontSize(10);
document.write(out);
} catch (IOException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
}
try {
out.close();
} catch (IOException ex) {
Logger.getLogger(WordDocCreation.class.getName()).log(Level.SEVERE, null, ex);
}
Systen正在编写文件,但是unicode文本显示为方框。
答案 0 :(得分:1)