*这么优秀的国产工具怎能错过呢!在线下单专享“一口价”,查看优惠价格!想要获取更多福利的朋友可以咨询在线客服哦~
代码示例
import com.spire.doc.Document;public class SplitWordBySection { public static void main(String[] args) { //创建Document对象 Document document = new Document(); //加载要拆分的文档 document.loadFromFile("C:\Users\Administrator\Desktop\sections.docx"); //声明新的Document对象 Document newWord; //遍历源文档中的节 for (int i = 0; i < document.getSections().getCount(); i++) { //初始化新的Document对象 newWord = new Document(); //将源文档中的指定节复制到新文档 newWord.getSections().add(document.getSections().get(i).deepClone()); //保存新文档到指定文件夹 newWord.saveToFile(String.format("C:\Users\Administrator\Desktop\Output\result-%d.docx", i)); } }}
源文档含三个节,因此被拆分成三个子文档:

还想要更多教程资源吗可以点击阅读【2020 · E-iceblue最新资源整合】,查找需要的教程资源。
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!