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