I am using apache POI for the first time.I am trying to read the value of a check-box from a word document(fixed template). But i am not getting the proper values(0 or 1) for unchecked and checked boxes respectively. Could anyone please help me with this? The code that I am using is as follows:
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class DocReader {
public void readDocFile()
{
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
try
{
docFile = new File("c:\\Temp.doc");
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
}
catch(Exception exep)
{
System.out.println(exep.getMessage());
}
String docArray[] = docExtractor.getParagraphText();
for(int i=116;i<118;i++)
{
if(docArray[i] != null)
System.out.println(docArray[i].trim());
}
}
public static void main(String[] args) {
DocReader reader = new DocReader();
reader.readDocFile();
}
}
---------------------------------------
The output is:
FORMCHECKBOX Option1
FORMCHECKBOX Option2
----------------------------------------
I simply copied the check boxes from the word file and pasted them to a text file and I am getting:
1 Option1
0 Option2
where Option1 is the checked check-box and Option2 is unchecked.
I was hoping to see something similar as the output of my java code.
Could anyone please help?
import java.io.File;
import java.io.FileInputStream;
import org.apache.poi.hwpf.HWPFDocument;
import org.apache.poi.hwpf.extractor.WordExtractor;
public class DocReader {
public void readDocFile()
{
File docFile = null;
WordExtractor docExtractor = null ;
WordExtractor exprExtractor = null ;
try
{
docFile = new File("c:\\Temp.doc");
FileInputStream fis=new FileInputStream(docFile.getAbsolutePath());
HWPFDocument doc=new HWPFDocument(fis);
docExtractor = new WordExtractor(doc);
}
catch(Exception exep)
{
System.out.println(exep.getMessage());
}
String docArray[] = docExtractor.getParagraphText();
for(int i=116;i<118;i++)
{
if(docArray[i] != null)
System.out.println(docArray[i].trim());
}
}
public static void main(String[] args) {
DocReader reader = new DocReader();
reader.readDocFile();
}
}
---------------------------------------
The output is:
FORMCHECKBOX Option1
FORMCHECKBOX Option2
----------------------------------------
I simply copied the check boxes from the word file and pasted them to a text file and I am getting:
1 Option1
0 Option2
where Option1 is the checked check-box and Option2 is unchecked.
I was hoping to see something similar as the output of my java code.
Could anyone please help?