This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Open Source Projects and the fly likes Reading text in a table from word document Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Reading text in a table from word document" Watch "Reading text in a table from word document" New topic
Author

Reading text in a table from word document

Jaikar Tulluri
Greenhorn

Joined: Dec 05, 2009
Posts: 2
Hi,
I am trying to read a word doc that contains a table using Java. The requirement is to create rows in a Database Table with the information extracted from the table in the word document.
For example, my word doc has a table like:

Heading Description
Heading1 summary related to heading1
Heading2 summary related to heading2
.....


And my database contains a table named SUMMARY with the following columns:

ID DateAdded FileName Heading1 Heading2 ..... (as many heading columns as the number of rows in my word document table)

So I need to read the document using java, get the description text for each heading and then store that text as a BLOB in the respective table column. I am currently checking the possibility of using POI for this requirement. I wrote an example application to store entire word doc as a BLOB to mysql database an dread it back. But I am not sure how to read rows of the table one by one. Any help is greatly appreciated.


Thanks,
JaiKar
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
A while ago I dabbled around with reading tables from Word documents with POI. I'm no longer working on that, but attached is some code i wrote for that purposes; it should point you in the right direction.


Ping & DNS - my free Android networking tools app
Jaikar Tulluri
Greenhorn

Joined: Dec 05, 2009
Posts: 2
Hi Ulf,
thank you very much for the response. I tested your example and its successfully retrieving text from table. I also wrote a sample java class that reads text from a Table in a word document. I was able to read the text in each cell of the table. But the problem I am facing is, if the cell has some text with bullets, while reading the cells I am not getting the bullets. the text() function of Cell class is returning only the plain text. So I was wondering if anyone ever tried reading the bullets along with the text using POI. I understand that POI has limited functionality. So I would like to know if it is possible or not to read bullets.

If my cell has some info like below:

The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:

* CREATE DATABASE - creates a new database
* ALTER DATABASE - modifies a database
* CREATE TABLE - creates a new table
* ALTER TABLE - modifies a table
* DROP TABLE - deletes a table


when I say cell.text(), the result is:

The DDL part of SQL permits database tables to be created or deleted. It also define indexes (keys), specify links between tables, and impose constraints between tables. The most important DDL statements in SQL are:
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table




Thanks,
Karuna
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41046
    
  43
Paragraph extends Range - you could inspect all the character runs of the range and see where that gets you.

HWPFDocument also has a getListTables method that may lead to something useful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading text in a table from word document
 
Similar Threads
to print a table in word(.doc file)
GUI Part - Bodgitt and Scarper
Optimizing a database
Reading word document
Displaying Table in Expanded and Collapsed manner