In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces what is the operation of Apache-xwpf to word, the content is very detailed, interested friends can refer to, hope to be helpful to you.
1. Xwpf document structure class
XWPFDocument XWPFWordExtractor word document object
XWPFParagraph paragraph
XWPFTable form
XWPFTableRow Lin
XWPFTableCell cell
XWPFRun region
CTTblPr Table Properties
2. Read word// read file FileInputStream inputStream=new FileInputStream ("D:\\ doc.doc"); / / File object XWPFDocument document=new XWPFDocument (inputStream); / / get all paragraphs List paragraphs=document.getParagraphs (); / / traverse output for (XWPFParagraph paras:paragraphs) {System.out.println ("11" + paras.getText ());} / / get all tables List tables = document.getTables (); List rows; List cells For (XWPFTable table1:tables) {rows=table1.getRows (); for (XWPFTableRow row:rows) {cells=row.getTableCells (); for (XWPFTableCell cell:cells) {System.out.println (cell.getText ());} inputStream.close (); commonly used api// to get all paragraphs List paragraphs=document.getParagraphs (); / / get all tables List tables = document.getTables () / / get all the slices List picList = document.getAllPictures (); third, write the word// creation document XWPFDocument document=new XWPFDocument (); / / create a paragraph XWPFParagraph paragraph=document.createParagraph (); / / xwpfRun represents a region of the same attribute XWPFRun run1=paragraph.createRun (); run1.setBold (true); run1.setText ("background: VR technology maturity has reached the critical point of market explosion, consumer products"); run1.setColor ("000000"); run1=paragraph.createRun () Run1.setText ("purpose: we connect the VR technology to the 3D printer and use the VR technology to type"); run1.setColor ("ff0000"); OutputStream oStream=new FileOutputStream ("D:\\ doc.doc"); [xss_clean] (oStream); oStream.close (); fourth, write the word form XWPFDocument document=new XWPFDocument (); / / create the table XWPFTable table=document.createTable (5d5); / / get each line int rowSize=rows.size (); int cellSize;XWPFTableCell cell;XWPFTableRow row;for (int item0teri)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.