Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to Use getViewableIterator in POI
    text
    copied!<p>I'm currently using POI to attempt to extract text out of a batch of Word documents and I need to be able to determine what entries a document contains. I've been able to get as far as pulling the document root and pulling the first entry but I want to be able to view all entries. The <code>getEntries()</code> method seems to provide this functionality but I'm at a loss as to how to use <code>getViewableIterator()</code> to pull them out. </p> <p>Below is what I have code-wise:</p> <pre><code>&lt;cfset myFile = createObject("java", "java.io.FileInputStream").init(fileInputPath)&gt; &lt;cfset fileSystem = CreateObject( "java", "org.apache.poi.poifs.filesystem.POIFSFileSystem" ).Init(myFile)&gt; &lt;cfloop from="1" to="#fileSystem.getRoot().getEntryCount()#" index="i"&gt; &lt;cfset viewableIterator = fileSystem.getRoot().getEntries().next().getViewableIterator()&gt; &lt;cfset nextEntry = fileSystem.getRoot().getEntries().next()&gt; &lt;cfif viewableIterator.hasNext()&gt; &lt;cfdump var="#nextEntry.getShortDescription()#"&gt; &lt;cfset viewableIterator.remove()&gt; &lt;/cfif&gt; &lt;/cfloop&gt; </code></pre> <p>On the first loop, I'm able to get the first entry just fine. However, I get an <code>java.lang.IllegalStateException</code> error as soon as <code>remove()</code> is executed. Obviously I'm not using the <code>remove()</code> method correctly but I haven't been able to find any examples of how this should be properly used. Any help would be greatly appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload