以下介绍了如何删除Word文档的最终空白段落。以C#程序代码为例,并将VB.NET代码附加为参考。
如下:
没有内容段落。
2.在程序中介绍以下必要的组装文件:
文档 ();doc.loadfromfile(“ test.docx”);//遍历foreach的部分(doc.sections中的部分){// {//遍历(int i = 0 = 0; i <e节。]作为paras paradraph; //删除空白段落的所有子类文本if(string.isnullOrenty(para.text.trim())){section.body.childobjects.remove(section.body.lastpaaragraph); i-;}}}}}} //“ outputfile.docx”,fileformat.docx2013); system.diagnostics.start(“ outputfile.docx”); rection.body.childobjects.removes.remove(section.body.lastparagraph)文档文档(savetofile(“ outputfile.docx”,fileformat.docx2013)system.diagnostics.process.start(“ outputfile.docx”)end end sub end sub end class class end end end end namespace
4.完成代码后,执行程序并生成结果文档。您可以查看文档中空白段的删除效果,如图所示: