• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Reading text in a table from word document

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jaikar Tulluri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic