Range r1 = doc.getRange(); for (int i = 0; i < r1.numSections(); ++i ) { Section s = r1.getSection(i); for (int x = 0; x < s.numParagraphs(); x++) {
protected void processDocumentPart( HWPFDocumentCore wordDocument, final Range range ) { for ( int s = 0; s < range.numSections(); s++ ) { processSection( wordDocument, range.getSection( s ), s ); } }
protected void processDocumentPart( HWPFDocumentCore wordDocument, final Range range ) { for ( int s = 0; s < range.numSections(); s++ ) { processSection( wordDocument, range.getSection( s ), s ); } }
public static void main(String[] args) throws IOException { HWPFDocument doc = new HWPFDocument(new FileInputStream(args[0])); Range r = doc.getRange(); System.out.println("Example you supplied:"); System.out.println("---------------------"); for (int x = 0; x < r.numSections(); x++) { Section s = r.getSection(x); for (int y = 0; y < s.numParagraphs(); y++) { Paragraph p = s.getParagraph(y); for (int z = 0; z < p.numCharacterRuns(); z++) { // character run CharacterRun run = p.getCharacterRun(z); // character run text String text = run.text(); // show us the text System.out.print(text); } // use a new line at the paragraph break System.out.println(); } } doc.close(); } }
Range r1 = doc.getRange(); Section sec = r1.getSection(r1.numSections()-1); Paragraph para = sec.getParagraph(sec.numParagraphs()-1); CharacterRun run = para.getCharacterRun(para.numCharacterRuns()-1); run.insertAfter("Hello World!!! It works well!!!"); run.setBold(true); run.setItalic(true); run.setCapitalized(true);
for (int x = 0; x < r.numSections(); x++)
public void processDocument( HWPFDocumentCore wordDocument ) { try { final SummaryInformation summaryInformation = wordDocument .getSummaryInformation(); if ( summaryInformation != null ) { processDocumentInformation( summaryInformation ); } } catch ( Exception exc ) { logger.log( POILogger.WARN, "Unable to process document summary information: ", exc, exc ); } final Range docRange = wordDocument.getRange(); if ( docRange.numSections() == 1 ) { processSingleSection( wordDocument, docRange.getSection( 0 ) ); afterProcess(); return; } processDocumentPart( wordDocument, docRange ); afterProcess(); }
public void processDocument( HWPFDocumentCore wordDocument ) { try { final SummaryInformation summaryInformation = wordDocument .getSummaryInformation(); if ( summaryInformation != null ) { processDocumentInformation( summaryInformation ); } } catch ( Exception exc ) { logger.log( POILogger.WARN, "Unable to process document summary information: ", exc, exc ); } final Range docRange = wordDocument.getRange(); if ( docRange.numSections() == 1 ) { processSingleSection( wordDocument, docRange.getSection( 0 ) ); afterProcess(); return; } processDocumentPart( wordDocument, docRange ); afterProcess(); }