电脑频道 手机频道
网络技术 路由器
电脑系统 电脑蓝屏
游戏攻略 明星八卦
电脑问答 最新更新
首页 > 文章列表页>正文 公告: 为响应国家净网行动,部分内容已经删除,感谢网友理解。

poi操作word书签 poi word模板书签替换

【2021-05-28 12:01:01】 来源:网络 作者:福州电脑之家 评论:

poi操作word书签

怎么使用JAVA,POI读写word文档

如何使用JAVA、POI读写word文档??能不能将一个word的内容完全读过来,放到一个新生成的word文件中去,要求能将word中的表格、图片等保留,格式不变。

最好能给个例子?网上多是很早以前的那个解决方法如下:,只能读文本内容,且新生成的word文件打开时总是要提示选择编码,不太好用,希望能有新的解决方案??!!poi操作word1.1 添加poi支持:包下载地址1.2 POI对Excel文件的读取操作比较方便,POI还提供对Word的DOC格式文件的读取。

但在它的发行版本中没有发布对Word支持的模块,需要另外下载一个POI的扩展的Jar包。

下载地址为;下载extractors-0.4_zip这个文件2、提取Doc文件内容 public static String readDoc(String doc) throws Exception {// 创建输入流读取DOC文件 FileInputStream in = new FileInputStream(new File(doc)); WordExtractor extractor = null; String text = null;// 创建WordExtractor extractor = new WordExtractor();// 对DOC文件进行提取 text = extractor.extractText(in); return text; } public static void main(String[] args) { try{ String text = WordReader.readDoc("c:/test.doc"); System.out.println(text); }catch(Exception e){ e.printStackTrace(); } }3、写入Doc文档 import java.io.ByteArrayInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.poifs.filesystem.DirectoryEntry; import org.apache.poi.poifs.filesystem.DocumentEntry; import org.apache.poi.poifs.filesystem.POIFSFileSystem; public class WordWriter { public static boolean writeDoc(String path, String content) { boolean w = false; try { // byte b[] = content.getBytes("ISO-8859-1"); byte b[] = content.getBytes(); ByteArrayInputStream bais = new ByteArrayInputStream(b); POIFSFileSystem fs = new POIFSFileSystem(); DirectoryEntry directory = fs.getRoot(); DocumentEntry de = directory.createDocument("WordDocument", bais); FileOutputStream ostream = new FileOutputStream(path); fs.writeFilesystem(ostream); bais.close(); ostream.close(); } catch (IOException e) { e.printStackTrace(); } return w; } public static void main(String[] args) throws Exception{ String wr=WordReader.readDoc("D:\\test.doc"); boolean b = writeDoc("D:\\result.doc",wr);

如何使用POI操作Word文本框中的内容

mport org.apache.poi.POITextExtractor;import org.apache.poi.hwpf.extractor.WordExtractor;org.apache.poi.hwpf.extractor.WordExtractor doc = new WordExtractor(new FileInputStream(filePath));String text = doc.getText();

JAVA使用POI读写word 乱码

写 public static void main(String args[]) throws Exception { XWPFDocument doc = new XWPFDocument(); XWPFParagraph p1 = doc.createParagraph(); p1.setAlignment(ParagraphAlignment.CENTER); p1.setBorderBottom(Borders.DOUBLE); p1.setBorderTop(Borders.DOUBLE); p1.setBorderRight(Borders.DOUBLE); p1.setBorderLeft(Borders.DOUBLE); p1.setBorderBetween(Borders.SINGLE); p1.setVerticalAlignment(TextAlignment.TOP); XWPFRun r1 = p1.createRun(); r1.setBold(true); r1.setText("The quick brown fox"); r1.setBold(true); r1.setFontFamily("Courier"); r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH); r1.setTextPosition(100); XWPFParagraph p2 = doc.createParagraph(); p2.setAlignment(ParagraphAlignment.RIGHT); p2.setBorderBottom(Borders.DOUBLE); p2.setBorderTop(Borders.DOUBLE); p2.setBorderRight(Borders.DOUBLE); p2.setBorderLeft(Borders.DOUBLE); p2.setBorderBetween(Borders.SINGLE); XWPFRun r2 = p2.createRun(); r2.setText("jumped over the lazy dog"); r2.setStrike(true); r2.setFontSize(20); XWPFRun r3 = p2.createRun(); r3.setText("and went away"); r3.setStrike(true); r3.setFontSize(20); r3.setSubscript(VerticalAlign.SUPERSCRIPT); XWPFParagraph p3 = doc.createParagraph(); p3.setWordWrap(true); p3.setPageBreak(true); p3.setAlignment(ParagraphAlignment.BOTH); p3.setSpacingLineRule(LineSpacingRule.EXACT); p3.setIndentationFirstLine(600); XWPFRun r4 = p3.createRun(); r4.setTextPosition(20); r4.setText("To be, or not to be: that is the question: Whether "tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles, And by opposing end them? To die: to sleep; "); r4.addBreak(BreakType.PAGE); r4.setText("No more; and by a sleep to say we end The heart-ache and the thousand natural shocks That flesh is heir to, "tis a consummation Devoutly to be wish"d. To die, to sleep; To sleep: perchance to dream: ay, there"s the rub; ......."); r4.setItalic(true); XWPFRun r5 = p3.createRun(); r5.setTextPosition(-10); r5.setText("For in that sleep of death what dreams may come"); r5.addCarriageReturn(); r5.setText("When we have shuffled off this mortal coil,Must give us pause: there"s the respectThat makes calamity of so long life;"); r5.addBreak(); r5.setText("For who would bear the whips and scorns of time,The oppressor"s wrong, the proud man"s contumely,"); r5.addBreak(BreakClear.ALL); r5.setText("The pangs of despised love, the law"s delay,The insolence of office and the spurns......."); FileOutputStream out = new FileOutputStream("simple.docx"); doc.write(out); out.close(); }

java poi 操作word的表格 怎么设置表格里面的字体加粗 现在只会把背景...

w;w;w。

可以将word的后缀名改为zip然后打开找到word/document;>dxa" />- eastAsia&quot:r>02w,这样可以更加方便的了解他的底层构造,获得到cell里的值,即cell.getText();在这里注意cell中value的长度:p>- w;w:tcPr>w; /首先就是要明白解决的方案是:先删后添。

就是利用Paragraph创建run,在创建完毕后循环遍历tableàrowàcell.xml文件...

poi word 图片 设置位置

如透传型POI。

大部分POI内部架构为2级,另一级为电桥。

也有少数POI是三级构架,端口数越多,损耗越大。

但是影响系数不是很大POI通路的插入损耗指标主要取决于内部架构的级数,会决定内部多频合路器端口数。

POI内部架构的级数是影响损耗的主要指标。

根据POI的定制要求,其中一级为多频段合路器,和内部多频合路器端口数...

下一篇:fuck什么意思

分享:
下载
发表关于《poi操作word书签 poi word模板书签替换》的评论

福州电脑网(福州iThome)专业电脑/计算机学习网站.提供电脑维修知识,包括计算机软件/硬件维修知识,路由器/交换机/网络设置,电脑蓝屏,网络/it知识学习等等电脑技术学习资料.

免责声明:本站所有信息内容仅供参考,如有冒犯您的权益请联系我们删除!请大家注意:本站删帖完全免费。邮箱:

Copyright (C) FziThome.com, All Rights Reserved.

版权所有 闽ICP备14002611号-3