aspose 生成word 簡單的文檔操作


package aspose.com.word;

import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;

public class CreateWord {
public static void main(String[] args) {
try {//載入模板
Document doc = new Document("C:\\Users\\admin\\Desktop\\test.docx");
DocumentBuilder docBuider = new DocumentBuilder(doc);
docBuider.write("");//填入內容,
//繪制一個5*5的表格 並填充內容
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
docBuider.insertCell();
docBuider.write("");//填入內容
}
docBuider.endRow();
}
docBuider.endTable();
doc.save("C:\\test1.docx");//保存文件
} catch (Exception e) {
e.printStackTrace();
}
}

}

 

 

需要aspose相關的word jar


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM