请问高手怎么样用java在word里插入一张图呢?

wordJava

1个回答

写回答

word
word

可以用wordapi组件来实现 代码大概是这样的:Javaimport com.heavenlake.wordapi.Document;public class test { public test() { Document doc = null; try { doc = new Document(); doc.open(e:/test.doc); // 打开文件 doc.insert(第一章:嘻嘻 biaoti); // 插入文字 doc.insertAtBookmark(testbookm, 第一章:嘻嘻 标题); doc.insertAtBookmark(testbookm, new Java.io.File(E:/照片/DSC236.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) { test test1 = new test(); }}

这段代码应该能实现你想要的功能,有需要可以拿去参考~

举报有用(0分享收藏

Copyright © 2025 IZhiDa.com All Rights Reserved.

知答 版权所有 粤ICP备2023042255号