aspose file tools*
The moose likes Java in General and the fly likes Dynamic table in word doc using apache poi Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Dynamic table in word doc using apache poi" Watch "Dynamic table in word doc using apache poi" New topic
Forums: Java in General Other Open Source Projects
Author

Dynamic table in word doc using apache poi

gopal g gupta
Greenhorn

Joined: Nov 06, 2011
Posts: 16
Hi All,

I want to create a dynamic table in word doc using apache poi. So for examples - In my case there are 9 rows. In 1st row there is only 1 column. In 2nd, 4th and 5th rows there are 2 columns. In 3rd and 6th rows there are 3 columns. In 7th, 8th and 9th rows there are 7 columns. Also, how can i set the text in bold for specific cell.

Take a look at the attached snapshot for more clarification.

Please let me know the approach. Its urgent.



[Thumbnail for Test.png]

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
This may not be possible. While the org.apache.poi.hwpf.usermodel.TableCell class has methods to determine whether an existing cell is merged with another cell, I don't see methods that would create merged cells, or let you merge cells after they have been created.


Ping & DNS - updated with new look and Ping home screen widget
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 1973
    
    7

If you plan to use a single table then it's practically impossible. Word isn't Excel.

However, you can split the relevant rows into sections and each section is its own table. This way you can use the org.apache.poi.hwpf.usermodel.TableRow class to align each row. If you do this, not sure if there will be space between each so-called table.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic table in word doc using apache poi
 
Similar Threads
Create word from html in servlet
showing the tooltip for a Dynamic datatable
how would i create a table with dynamic rows and columns using only JSF components?
data from data base to excel in servlet
Reading text in a table from word document