文檔首頁(yè)>>Spire.Doc系列教程>>Spire.Doc功能演示:在Java中以編程方式將數(shù)學(xué)方程式插入Word
Spire.Doc功能演示:在Java中以編程方式將數(shù)學(xué)方程式插入Word
Spire.Doc for Java 是一款專業(yè)的Java Word組件,開(kāi)發(fā)人員使用它可以輕松地將Word文檔創(chuàng)建、讀取、編輯、轉(zhuǎn)換和打印等功能集成到自己的Java應(yīng)用程序中。
本文將演示如何在Java應(yīng)用程序中使用Spire.Doc for Java到Latex Math方程和MathMLCode到Word文檔???a href="http://www.xiangyinys.com/product/4184/download" target="_blank">點(diǎn)擊此處下載最新版測(cè)試。
import com.spire.doc.*; import com.spire.doc.documents.*; import com.spire.doc.fields.omath.*; public class wordEquation { public static void main(String[] args){ //Create a new instance of Word and add a section Document doc = new Document(); Section section = doc.addSection(); //Add a paragraph Paragraph paragraph = section.addParagraph(); //Add Latex Math code OfficeMath officeMath = new OfficeMath(doc); paragraph.getItems().add(officeMath); officeMath.fromLatexMathCode("x^{2}+\\sqrt{{x^{2}+1}}+1"); //Add another paragraph Paragraph paragraph2 = section.addParagraph(); //Add MathMLCode OfficeMath officeMath2 = new OfficeMath(doc); paragraph2.getItems().add(officeMath2); officeMath2.fromMathMLCode("x2+x2+1+1"); //Save the document to file String result = "output/addMathEquation.docx"; doc.saveToFile(result, FileFormat.Docx_2013); } }
輸出結(jié)果