자바 프로그램 생 성 공식 docx 문서 에서
package cn.com.eduedu.jee.util;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.xwpf.usermodel.*;
import org.openxmlformats.schemas.officeDocument.x2006.math.CTOMath;
import org.openxmlformats.schemas.officeDocument.x2006.math.CTRad;
import org.openxmlformats.schemas.officeDocument.x2006.math.CTR;
import org.openxmlformats.schemas.officeDocument.x2006.math.STStyle;
public class MSDocxCreateFormulaInDocx {
public static void main(String[] args) throws FileNotFoundException, IOException {
XWPFDocument doc= new XWPFDocument();
XWPFParagraph paragraph = doc.createParagraph();
XWPFRun run=paragraph.createRun();
run.setText("The Formula: ");
CTOMath cTOMath = paragraph.getCTP().addNewOMath();
CTR cTR = cTOMath.addNewR();
cTR.addNewRPr().addNewSty().setVal(STStyle.P);
cTR.addNewT2().setStringValue("a²+b²=c²");
run=paragraph.createRun();
run.setText(" text after the formula");
paragraph = doc.createParagraph();
run=paragraph.createRun();
run.setText("The Formula: ");
cTOMath = paragraph.getCTP().addNewOMath();
CTRad cTRad = cTOMath.addNewRad();
cTR = cTRad.addNewDeg().addNewR();
cTR.addNewRPr().addNewSty().setVal(STStyle.P);
cTR.addNewT2().setStringValue("2");
cTR = cTRad.addNewE().addNewR();
cTR.addNewRPr().addNewSty().setVal(STStyle.P);
cTR.addNewT2().setStringValue("a²+b²");
run=paragraph.createRun();
run.setText(" text after the formula");
doc.write(new FileOutputStream("d:\\WordFormula.docx"));
doc.close();
}
}
옮 겨 실 었 는데 어디서 돌 았 는 지 못 찾 겠 어 요.죄송합니다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.