用到Java2Word.jar,可在本博客文件中下载
import com.heavenlake.wordapi.Document;
public class testWORD {
public testWORD() {
Document doc = null;
try {
doc = new Document();
doc.open("C:/test.doc");
doc.insert("第一章:宪政概论","正文");
doc.insertAtBookmark("testbookm","第一章:宪政概论\n地方大幅度","正文");
doc.insertAtBookmark("testbookm",
new java.io.File("D:/DOC/My Pictures/ycj_044.jpg"));
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
if(doc!=null) doc.close(true);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
testWORD test1 = new testWORD();
}
}