Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何设置;“拉萨”;使用poi jar写入docx文件时默认使用字体_Java_Apache Poi - Fatal编程技术网

Java 如何设置;“拉萨”;使用poi jar写入docx文件时默认使用字体

Java 如何设置;“拉萨”;使用poi jar写入docx文件时默认使用字体,java,apache-poi,Java,Apache Poi,我需要使用ApachePOI创建一个docx文件,并且需要将其字体设置为Latha。下面是我的代码,但当我使用setfontfamily(“Latha”)时,它不起作用。拉萨是泰米尔字体 XWPFDocument document = new XWPFDocument(); FileOutputStream out = null; try { out = new FileOutputStream(new File("PageCounter.docx"));

我需要使用ApachePOI创建一个docx文件,并且需要将其字体设置为Latha。下面是我的代码,但当我使用setfontfamily(“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文本显示为方框。

这是3.7中的一个错误:

但在3.8版本中工作(目前处于测试阶段):

我使用相同版本的poi jar 3.10进行poi,也使用docj4 jar,我获得了所需的输出。poi 3.8是在3年前发布的!最新的ApachePOI版本是3.12,于2015年5月发布。为了设置泰米尔字体,我们必须使用这两种方法。xssfont.setFontName(“Latha”);assertEquals(“Latha”,ctFont.getNameArray(0.getVal());run.setFontFamily(“Latha”)‌​; run.setText(replaceAll2);如果您没有找到所需的答案,请使用getCTR()方法。然后在ApacheOffice中,它的工作将在Ms word中出现一些错误