This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Read the value of checkboxes from word document programatically with java using POI APIs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Read the value of checkboxes from word document programatically with java using POI APIs" Watch "Read the value of checkboxes from word document programatically with java using POI APIs" New topic
Author

Read the value of checkboxes from word document programatically with java using POI APIs

Mrigen Negi
Greenhorn

Joined: Apr 02, 2008
Posts: 2
Hello All,

I am using POI APIs to read the contents of a word document which has checkboxes and dropdowns in it for data entry.
Below is the code I am using :

String fileName = "C:/Users/Apit/Desktop/xyz.doc";
InputStream fis;
try {
fis = new FileInputStream(fileName);
POIFSFileSystem fs = new POIFSFileSystem(fis);
HWPFDocument doc = new HWPFDocument(fs);

Range range = doc.getRange();

for (int i=0; i<range.numParagraphs(); i++) {
Paragraph par = range.getParagraph(i);
System.out.println("paragraph "+(i+1));
System.out.println("is in table: "+par.isInTable());
System.out.println("is table row end: "+par.isTableRowEnd());
System.out.println(par.text());
par.

}

Paragraph tablePar = range.getParagraph(0);
if (tablePar.isInTable()) {
Table table = range.getTable(tablePar);
for (int rowIdx=0; rowIdx><table.numRows(); rowIdx++) {
TableRow row = table.getRow(rowIdx);
System.out.println("row "+(rowIdx+1)+", is table header: "+row.isTableHeader());
for (int colIdx=0; colIdx><row.numCells(); colIdx++) {
TableCell cell = row.getCell(colIdx);
System.out.println("column "+(colIdx+1)+", text="+cell.getParagraph(0).text());


}
Following is the output :

WARN : 17:57:11,307 - TcLogger$IC_PrintStream.log:?
PART C: CHANGE CATEGORY / TO BE FULFILLED BY PROJECT LEAD ENGINEER

WARN : 17:57:11,374 - TcLogger$IC_PrintStream.log:?
 FORMTEXT ?? /  FORMDROPDOWN  /  FORMDROPDOWN 

WARN : 17:57:11,316 - TcLogger$IC_PrintStream.log:?
 FORMCHECKBOX  Experimental Change

Can anyone please help as how to use the POI APIs further to actually find out whether the user has checked the checkbox or not ,also to know the dropdown value selected?

Thanks and Regards,
Apit

">
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read the value of checkboxes from word document programatically with java using POI APIs